EXEPERTAI LAB

Research alpha

Time Machine
EXEPERTAI LAB
GALLERY / COLLECTION
← Browse Astryx gallery
Selector·component·@astryxdesign/core

Selector Option

Helper component for custom item rendering inside an Selector renderOption prop.

Open in Playground @astryxdesign/core/Selector

Showcases and examples

2 documented examples

Selector Option

Selector with custom-rendered options using SelectorOption for icons and descriptions.

Preview loads on approachPreview loads on approach
Exact source · selector-option-showcase
// Copyright (c) Meta Platforms, Inc. and affiliates.

'use client';

import {useState} from 'react';
import {Selector, SelectorOption} from '@astryxdesign/core/Selector';
import {UserIcon} from '@heroicons/react/24/outline';

const descriptions: Record<string, string> = {
  admin: 'Full access to all resources',
  editor: 'Can edit and publish content',
  viewer: 'Read-only access',
  billing: 'Manage plans and payments',
};

const roles = [
  {value: 'admin', label: 'Admin'},
  {value: 'editor', label: 'Editor'},
  {value: 'viewer', label: 'Viewer'},
  {value: 'billing', label: 'Billing'},
];

export default function SelectorOptionShowcase() {
  const [value, setValue] = useState<string | undefined>('editor');

  return (
    <Selector
      style={{width: 300}}
      label="Role"
      options={roles}
      value={value}
      onChange={setValue}
      placeholder="Assign a role..."
      renderOption={option => (
        <SelectorOption
          icon={UserIcon}
          label={option.label}
          description={descriptions[option.value]}
        />
      )}
    />
  );
}

Usage

Helper component for custom item rendering inside an Selector renderOption prop.

Typed props

PropType and behavior
labelReactNode · required
Primary label text for the item.
iconIconType
Icon displayed before the label. See astryx docs icons for valid semantic names.
descriptionReactNode
Secondary description text displayed below the label.
layout'stacked' | 'inline' · default 'stacked'
How the label and description sit together. 'stacked' puts the description on its own line; 'inline' keeps both on one line so the row fits a fixed-height host. Inside a Selector trigger the trigger's padding sizes itself to whichever layout you pick, so both land on the 4px rhythm; an InputGroup pins the row height and forces 'inline'.
endContentReactNode
Additional content rendered after the label and description.