Components · engine.option · version 0.3.0

Option

One choice in a select's list.

Preview

Every variant in every state, drawn by the same definition that the Figma sync and the tests use.

option in every variant and state
Componentrestdisabledselectedselected, disabledactiveactive, selected
option
Option
Option
Option
Option
Option
Option

Install

npm install @uiuxengine/react

Components come from npm and stay identical to their definition and their Figma component. See Installation.

Usage

import { Option } from "@uiuxengine/react";

export function Example() {
  return (
    <Option label="Option" value="value" />
  );
}

Guidelines

  • Use only inside a select.
  • Values are unique within a select and stay the same when labels change; the label is what people read.
  • Disable an option that can't be chosen now rather than removing it, so the list keeps its shape.

Props

PropTypeDefaultDescription
value requiredtext, up to 200—Identifies the option. The select's value is the chosen option's value.
label requiredtext, up to 120—The text people read.
disabledbooleanfalseShown, but can't be chosen.

Accessibility

  • Renders a native <div> with the role option.
  • selected is announced as aria-selected.
  • disabled is announced as aria-disabled.

As a spec

Agents describe interfaces as JSON specs. A spec renders only after it validates against the installed contracts, the approved icons and the host's actions. Edit it to see. Options render in a Select, so this spec has some in one.

Apple
Banana
Cherry

No actions yet.

JSON Schema of the props
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "urn:uiuxengine:component:engine.option@0.3.0",
  "title": "option",
  "description": "One choice in a select's list.",
  "type": "object",
  "properties": {
    "value": {
      "description": "Identifies the option. The select's value is the chosen option's value.",
      "type": "string",
      "maxLength": 200
    },
    "label": {
      "description": "The text people read.",
      "type": "string",
      "maxLength": 120
    },
    "disabled": {
      "description": "Shown, but can't be chosen.",
      "type": "boolean",
      "default": false
    }
  },
  "required": [
    "value",
    "label"
  ],
  "additionalProperties": false,
  "$defs": {
    "iconRef": {
      "type": "object",
      "description": "A reference to an icon in the host's approved catalog.",
      "properties": {
        "type": {
          "const": "icon"
        },
        "id": {
          "type": "string",
          "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
        },
        "style": {
          "type": "string",
          "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
        },
        "weight": {
          "type": "string",
          "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
        }
      },
      "required": [
        "type",
        "id"
      ],
      "additionalProperties": false
    }
  }
}