About
Helper component for custom item rendering inside an Selector renderOption prop. Astryx by Meta. Source: https://astryx.atmeta.com/components/SelectorOption
Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Astryx Selector Option to your project and fits it to your theme.
Code
How Astryx Selector Option is used: the demo's code. The component's own source comes with a free account.
Usage.tsx
'use client';
/* Copyright (c) 2026 Meta Platforms, Inc. See the MIT notice in astryx-selector-option.tsx. */
import '@/components/ui/astryx-selector-option-utils/astryx-preview.css';
import '@astryxdesign/theme-neutral/fonts.css';
import {useSyncExternalStore} from 'react';
import {Theme} from '@astryxdesign/core/theme';
import {neutralTheme} from '@astryxdesign/theme-neutral/built';
import {useState} from 'react';
import {Selector, SelectorOption} from '@/components/ui/astryx-selector-option';
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'},
];
function OfficialSample() {
const [value, setValue] = useState<string | undefined>('editor');
return (
<Selector
width="100%"
placement="below"
label="Role"
options={roles}
value={value}
onChange={setValue}
placeholder="Assign a role..."
renderOption={option => (
<SelectorOption
icon={UserIcon}
label={option.label}
description={descriptions[option.value]}
/>
)}
/>
);
}
function readPreviewMode() {
const {classList} = document.documentElement;
return classList.contains('dark') ? 'dark' : 'light';
}
function subscribeToPreviewMode(callback: () => void) {
const observer = new MutationObserver(callback);
observer.observe(document.documentElement, {attributes: true, attributeFilter: ['class']});
return () => observer.disconnect();
}
export default function Demo() {
const mode = useSyncExternalStore(subscribeToPreviewMode, readPreviewMode, () => 'light' as const);
return (
<Theme theme={neutralTheme} mode={mode}>
<div className="astryx-demo">
<div className="astryx-demo-content" data-centered style={{maxWidth: 300}}>
<OfficialSample />
</div>
</div>
</Theme>
);
}















