Skip to content

SettingsSection and SettingsRow ​

The parts a settings pane is built from. A SettingsSection is a titled card of rows, and a SettingsRow is one setting: what it is on the left, the control on the right.

tsx
import { SettingsRow, SettingsSection, TopIcon } from '@adecore/ui/settings';
tsx
import { Button, Pill, Select, Switch } from '@adecore/ui';
import { SettingsRow, SettingsSection, TopIcon } from '@adecore/ui/settings';
import { Globe, Monitor } from 'lucide-react';
import { useState } from 'react';

export default function SettingsSectionDemo() {
    const [updates, setUpdates] = useState(true);
    const [beta, setBeta] = useState(false);
    const [channel, setChannel] = useState('stable');

    return (
        <SettingsSection
            className="w-full max-w-xl"
            title="Updates"
            icon={Globe}
            description="How this app stays current."
            tag={<Pill shape="tag">This computer</Pill>}
            action={
                <Button size="sm" variant="secondary">
                    Check now
                </Button>
            }
            footer="The last check was a minute ago."
        >
            <SettingsRow
                label="Install updates automatically"
                description="Downloads in the background and installs when you quit."
                control={<Switch label="Install updates automatically" checked={updates} onCheckedChange={setUpdates} />}
            />
            <SettingsRow indent label="Include betas" control={<Switch label="Include betas" checked={beta} onCheckedChange={setBeta} />} />
            <SettingsRow
                label="Channel"
                leading={<TopIcon icon={Monitor} className="text-text-faint" />}
                control={
                    <Select
                        label="Channel"
                        value={channel}
                        onValueChange={setChannel}
                        items={[
                            { value: 'stable', label: 'Stable' },
                            { value: 'nightly', label: 'Nightly' }
                        ]}
                    />
                }
            />
            <SettingsRow muted label="Version 1.0.0" />
        </SettingsSection>
    );
}

SettingsSection ​

A header with a title, a description, an action on the right and a tag after it, then the rows in one card, divided by hairlines. Without header props the section is the card alone.

The card reaches 19px out on both sides, a row's inset plus its border, so the words of a row start where the title does. Leave at least that much room beside a section, as the panes of SettingsDialog do.

PropTypeDefault
childrenReactNodeRequired. The rows.
titlestringAlso the section's accessible name.
descriptionReactNode
iconLucideIconBefore the title, muted, for a pane whose sections are kinds of thing.
tagReactNode
actionReactNode
footerReactNodeA note under the card, in the faint color.
classNamestring
refRef<HTMLElement>

SettingsRow ​

In a narrow window the control wraps under the label. Give the control its own accessible name, such as a label on a Switch or Select.

indent nests a row under the one above, for a setting that depends on it. muted mutes the label, for a row that only shows state. children go under the label at full width, such as swatches. leading sits before the label: a TopIcon or a tile.

PropTypeDefault
labelReactNodeRequired.
descriptionReactNode
controlReactNode
childrenReactNode
mutedbooleanfalse
leadingReactNode
indentbooleanfalse
searchIdstringThe id a search result names to lead here. See search.
classNamestring
refRef<HTMLDivElement>

TopIcon ​

An icon that stays on the first line of wrapping text. It takes icon, size (default 16), className (on the icon) and ref (on the box).

useSettingsTarget ​

A row a search result leads to scrolls into view and flashes. For a control of your own that should react too, such as opening a disclosure, call useSettingsTarget(). It returns { target, shown }: the searchId jumped to or null, and the function to call once shown.

SettingsSectionProps, SettingsRowProps and TopIconProps are exported types.

Licenses and third-party notices are listed in each package.