# Settings group

> A titled block of field rows, for settings screens. A native Pyzed component for Python desktop GUIs, with a live preview, code examples and its API.

Source: https://albakore.github.io/pyzed/library/settings-group/

:::tip[In plain words]
A titled block of settings, like a section of a preferences window.
:::

A titled block of `ui.field` rows separated by lines, with an optional description, like a settings screen.

`ui.settings_group` · Category: [Data](https://albakore.github.io/pyzed/library/#data) · [Full reference →](https://albakore.github.io/pyzed/reference/ui/#settings_group)

**Code:**

```python
pz.container(ui.settings_group("Editor", [
    ui.field("Font size", ui.number_field(14, on_change, suffix="px")),
    ui.field("Soft wrap", ui.switch(True, on_toggle)),
    ui.field("Theme", ui.select(["One Dark", "One Light"], "One Dark", on_select, width=150)),
], description="Editor preferences."), width=460)
```

## When to use

- To organize a preferences screen into sections (Editor, Files, Git…).

## Usage

```python
import pyzed as pz
from pyzed import ui

pz.container(ui.settings_group("Editor", [
    ui.field("Font size", ui.number_field(14, on_change, suffix="px")),
    ui.field("Soft wrap", ui.switch(True, on_toggle)),
    ui.field("Theme", ui.select(["One Dark", "One Light"], "One Dark", on_select, width=150)),
], description="Editor preferences."), width=460)
```

## Variants

:::note[About these captures]
Each capture is recorded by pyzed itself, off-screen at 2x, in One Dark or One Light to match this site's theme, and cropped to the component so it shows at its real size. The pointer hovers, presses or types into it; a component that does not react to the pointer cycles through a few themes. With reduced motion you see the first frame. Open **Code** under a capture to see the snippet that draws it; free names such as `on_save` stand for your own callbacks.
:::

### Options

```python
pz.container(ui.settings_group("Files", [
    ui.field("Autosave", ui.switch(True, on_toggle)),
    ui.field("Trim whitespace", ui.checkbox(False, on_toggle)),
]), width=380)
```

```python
pz.container(ui.settings_group("Git", [
    ui.field("Inline blame", ui.switch(False, on_toggle)),
], description="Shown in the editor gutter."), width=380)
```

### States and events

```python
pz.container(ui.settings_group("Editor", [ui.field("Wrap lines", ui.switch(True, on_toggle))],
                               end=ui.button("Reset", on_press, size="sm", variant="ghost")), width=420)
```

## Events

Settings group has no events of its own: it shows what you give it. Like every widget it also has the **18 common events** (`click`, `double_click`, `right_click`, `mouse_enter`, `drag`, `key_down`, `resize`…), attached with `.on(...)`: see [Events](https://albakore.github.io/pyzed/guides/events/) and [Events of every component](https://albakore.github.io/pyzed/library/events/).

## Properties and API

### `ui.settings_group`

```python
settings_group(title, rows, *, description=None, end=None, theme=None)
```

A titled block of `ui.field` rows separated by lines, like a settings screen.

| Property | Default | Description |
| --- | --- | --- |
| `title` | *required* | Group title. |
| `rows` | *required* | The rows (usually `ui.field`). |
| `description` | `None` | Secondary text. |
| `end` | `None` | Widget at the right of the title (a Reset button…). |
| `theme` | `None` | Theme to use instead of the current one (`pyzed.theme.current()`). |

[Full reference →](https://albakore.github.io/pyzed/reference/ui/#settings_group)

## Related

- [Field](https://albakore.github.io/pyzed/library/field/): A settings row: title and description left, control right.
- [Accordion](https://albakore.github.io/pyzed/library/accordion/): Stacked collapsible sections, like the panels of a settings screen.
- [Card](https://albakore.github.io/pyzed/library/card/): A bordered surface with an optional title and actions.
