Components

Panel

A titled card of rows, as on a settings page: text on one side, controls on the other.

import * as stylex from '@stylexjs/stylex'

import { Button } from 'nyctoui/button'
import { Input } from 'nyctoui/input'
import { Label } from 'nyctoui/label'
import {
  Panel,
  PanelContent,
  PanelDescription,
  PanelHeader,
  PanelItem,
  PanelItemActions,
  PanelItemContent,
  PanelItemDescription,
  PanelItemTitle,
  PanelTitle,
} from 'nyctoui/panel'
import {
  Select,
  SelectContent,
  SelectItem,
  SelectTrigger,
  SelectValue,
} from 'nyctoui/select'
import { sizes } from 'nyctoui/tokens.stylex'

const weekdays = { sunday: 'Sunday', monday: 'Monday', saturday: 'Saturday' }

export default function PanelDemo() {
  return (
    <Panel sx={styles.panel}>
      <PanelHeader>
        <PanelTitle>General</PanelTitle>
        <PanelDescription>Settings that apply to the whole team.</PanelDescription>
      </PanelHeader>
      <PanelContent>
        <PanelItem>
          <PanelItemContent>
            <PanelItemTitle render={<Label htmlFor="panel-team-name" />}>
              Team name
            </PanelItemTitle>
            <PanelItemDescription>Shown in the sidebar and in URLs</PanelItemDescription>
          </PanelItemContent>
          <PanelItemActions>
            <Input id="panel-team-name" defaultValue="Engineering" sx={styles.input} />
          </PanelItemActions>
        </PanelItem>
        <PanelItem>
          <PanelItemContent>
            <PanelItemTitle render={<Label htmlFor="panel-week-start" />}>
              First day of the week
            </PanelItemTitle>
            <PanelItemDescription>Used for date pickers and cycles</PanelItemDescription>
          </PanelItemContent>
          <PanelItemActions>
            <Select items={weekdays} defaultValue="monday">
              <SelectTrigger id="panel-week-start">
                <SelectValue />
              </SelectTrigger>
              <SelectContent>
                {Object.entries(weekdays).map(([value, label]) => (
                  <SelectItem key={value} value={value}>
                    {label}
                  </SelectItem>
                ))}
              </SelectContent>
            </Select>
          </PanelItemActions>
        </PanelItem>
        <PanelItem>
          <PanelItemContent>
            <PanelItemTitle>Delete team</PanelItemTitle>
            <PanelItemDescription>Removes its issues, cycles and projects</PanelItemDescription>
          </PanelItemContent>
          <PanelItemActions>
            <Button variant="ghost">Archive instead</Button>
            <Button variant="danger">Delete</Button>
          </PanelItemActions>
        </PanelItem>
      </PanelContent>
    </Panel>
  )
}

const styles = stylex.create({
  panel: { width: '100%', maxWidth: sizes._300 },
  input: { width: sizes._100 },
})

Usage

import {
  Panel,
  PanelContent,
  PanelDescription,
  PanelHeader,
  PanelItem,
  PanelItemActions,
  PanelItemContent,
  PanelItemDescription,
  PanelItemTitle,
  PanelTitle,
} from 'nyctoui/panel'

<Panel>
  <PanelHeader>
    <PanelTitle>General</PanelTitle>
    <PanelDescription>Settings for the whole team.</PanelDescription>
  </PanelHeader>
  <PanelContent>
    <PanelItem>
      <PanelItemContent>
        <PanelItemTitle>Team name</PanelItemTitle>
        <PanelItemDescription>Shown in the sidebar</PanelItemDescription>
      </PanelItemContent>
      <PanelItemActions>…</PanelItemActions>
    </PanelItem>
  </PanelContent>
</Panel>

Rows stack when the card itself is narrower than 520px, not the viewport, so a panel in a split view or a sidebar stacks too. Try it at a phone width.

Good for

  • An account settings page, with one panel each for Profile, Security and Notifications.
  • A project’s danger zone, with Transfer and Delete rows.
  • A list of connected integrations, each row with its status and a Manage button.
  • A billing summary card with plan, renewal date and a change button.

Examples

Free content

PanelContent is only the card surface, so it takes any content, rows or not.

Every part takes render. Here each row is a router link with a hover fill added through sx.

Best practices

Do
  • Give each panel a PanelTitle that names one group of settings.
  • Write each row’s title as what it controls, and put any detail in PanelItemDescription.
  • Keep one control per row in PanelItemActions, such as a switch, a select or a button.
  • Check the panel at a narrow width; rows stack when the card gets narrow.
Don’t
  • Put a panel inside another panel.
  • Use a panel to frame every part of a page. Headings and space can group things without a border.
  • Mix unrelated settings in one panel because they fit.

API reference

Every part is a plain element rendered with ui-sdk’s renderElement. It takes that element’s props, plus render and sx.

Panel

A <section> holding the header and the card.

PropTypeDefault
render
Replaces the default element.
ReactElement | function—
sx
StyleX styles merged after the built-in ones.
StyleXStyles—

PanelHeader

A <div> for the title and description above the card.

PropTypeDefault
render
Replaces the default element.
ReactElement | function—
sx
StyleX styles merged after the built-in ones.
StyleXStyles—

PanelTitle

An <h2>. Pass render={<h3 />} to fit the page’s outline.

PropTypeDefault
render
Replaces the default element.
ReactElement | function—
sx
StyleX styles merged after the built-in ones.
StyleXStyles—

PanelDescription

A <p> of secondary text under the title.

PropTypeDefault
render
Replaces the default element.
ReactElement | function—
sx
StyleX styles merged after the built-in ones.
StyleXStyles—

PanelContent

The raised card; a size container for its rows.

PropTypeDefault
render
Replaces the default element.
ReactElement | function—
sx
StyleX styles merged after the built-in ones.
StyleXStyles—

PanelItem

One row. Rows after the first get a hairline divider.

PropTypeDefault
render
Replaces the default element.
ReactElement | function—
sx
StyleX styles merged after the built-in ones.
StyleXStyles—

PanelItemContent

The text column of a row.

PropTypeDefault
render
Replaces the default element.
ReactElement | function—
sx
StyleX styles merged after the built-in ones.
StyleXStyles—

PanelItemTitle

The row’s label. Pass render={<Label htmlFor="…" />} when it names a single control.

PropTypeDefault
render
Replaces the default element.
ReactElement | function—
sx
StyleX styles merged after the built-in ones.
StyleXStyles—

PanelItemDescription

Secondary text under the row’s title.

PropTypeDefault
render
Replaces the default element.
ReactElement | function—
sx
StyleX styles merged after the built-in ones.
StyleXStyles—

PanelItemActions

Controls at the end of the row. They wrap when there is not enough room.

PropTypeDefault
render
Replaces the default element.
ReactElement | function—
sx
StyleX styles merged after the built-in ones.
StyleXStyles—