Imperative Surface Imperative Surface

Selection Sheet

Sheets are useful for mobile-friendly selections.

type Option = {
  id: string;
  label: string;
};

const options: Option[] = [
  { id: '1', label: 'First' },
  { id: '2', label: 'Second' },
  { id: '3', label: 'Third' },
];

function SelectionSheet({
  pop,
}: SurfaceContext<Option>) {
  return (
    <Surface.Body>
      <Surface.Header
        title="Choose an option"
        centerTitle
        onPop={() => pop()}
      />

      <Surface.Content>
        {options.map((option) => (
          <button
            key={option.id}
            onClick={() => pop(option)}
          >
            {option.label}
          </button>
        ))}
      </Surface.Content>
    </Surface.Body>
  );
}

const selected = await Surface.Sheet.present<Option>({
  position: 'bottom',
  size: 'large',
  body: SelectionSheet,
});

On screens up to 1024px, position: 'auto' already defaults to a bottom sheet, so the explicit position can be omitted when that responsive behavior is desired.

On this page