Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
6df5cb8
init new hooks docs: useButton, useListBox, useSelect
reidbarber Jun 2, 2026
4d94c43
ts docs fix
reidbarber Jun 2, 2026
acfa1d2
fix links
reidbarber Jun 2, 2026
3b692b6
update useSelect example to use Button, Popover, and Listbox componen…
reidbarber Jun 3, 2026
658342e
add useComboBox docs
reidbarber Jun 8, 2026
2c02c66
add useMenu docs
reidbarber Jun 8, 2026
6cb6d52
add useDatePicker docs
reidbarber Jun 8, 2026
4167b75
add useDateRangePicker docs
reidbarber Jun 8, 2026
d106bf9
add usePopover docs
reidbarber Jun 8, 2026
4189ee1
add useModalOverlay docs
reidbarber Jun 8, 2026
39657ec
add useDIalog docs
reidbarber Jun 8, 2026
a4caa5d
add useTooltipTrigger docs
reidbarber Jun 8, 2026
b1e0915
add useCalendar docs
reidbarber Jun 8, 2026
2da1139
add useRangeCalendar docs
reidbarber Jun 8, 2026
bf9d337
add useDisclosure docs
reidbarber Jun 8, 2026
ad0d654
add useToolbar docs
reidbarber Jun 8, 2026
b77774d
add useToast docs
reidbarber Jun 8, 2026
27ad863
add useNumberField docs
reidbarber Jun 8, 2026
fe4dc45
add useSeparator docs
reidbarber Jun 8, 2026
6d098d7
add useLink docs
reidbarber Jun 8, 2026
e9ee7ac
add useBreadcrumbs docs
reidbarber Jun 8, 2026
d8a0ef7
add useMeter docs
reidbarber Jun 8, 2026
d104b44
add useProgressBar docs
reidbarber Jun 8, 2026
5c9782b
add useCheckbox docs
reidbarber Jun 8, 2026
1be2931
add useSwitch docs
reidbarber Jun 8, 2026
0e10bdf
add useToggleButton docs
reidbarber Jun 8, 2026
19cd14f
add useRadioGroup docs
reidbarber Jun 8, 2026
22ba183
add useCheckboxGroup docs
reidbarber Jun 8, 2026
aee45f1
add useToggleButtonGroup docs
reidbarber Jun 8, 2026
cc49fa3
add useTextField docs
reidbarber Jun 8, 2026
27d97c1
add useDateField docs
reidbarber Jun 8, 2026
8ae7262
add useTimeField docs
reidbarber Jun 8, 2026
351d380
add useSearchField docs
reidbarber Jun 8, 2026
5d5a566
add useSlider docs
reidbarber Jun 8, 2026
f3f11ed
add useColorSwatch docs
reidbarber Jun 8, 2026
a0e87b3
add useColorField docs
reidbarber Jun 8, 2026
976fd21
add useColorArea docs
reidbarber Jun 8, 2026
8d698c5
add useColorSlider docs
reidbarber Jun 8, 2026
bcad762
add useColorWheel docs
reidbarber Jun 8, 2026
331c413
add useTagGroup docs
reidbarber Jun 8, 2026
c4405ba
add useGridList docs
reidbarber Jun 8, 2026
6c35971
add useTable docs
reidbarber Jun 8, 2026
745b08c
add useDraggableCollection docs
reidbarber Jun 8, 2026
9b89a81
add useDroppableCollection docs
reidbarber Jun 8, 2026
95ff49d
Merge remote-tracking branch 'origin/main' into new-hook-docs
reidbarber Jun 8, 2026
2c4fd28
add <br /> between adjacent FunctionAPIs
reidbarber Jun 9, 2026
7de8271
add useTabList docs
reidbarber Jun 9, 2026
4a3e2f3
add useListFormatter docs
reidbarber Jun 9, 2026
3dc0411
add docs for composeRenderProps and useRenderProps to Customization page
reidbarber Jun 9, 2026
db48c7d
document focus containment behavior in useModalOverlay
reidbarber Jun 9, 2026
4d12892
add tags to Customization page
reidbarber Jun 9, 2026
af143c2
map hooks to component illustrations
reidbarber Jun 9, 2026
a3714da
Fix FunctionAPI, remove Features sections, add anatomy diagrams
reidbarber Jun 9, 2026
e47c3b1
update examples to use Typescript
reidbarber Jun 9, 2026
abbfafd
add hooks starter
reidbarber Jun 10, 2026
4dfeba7
clean up hooks starter
reidbarber Jun 11, 2026
b61199a
clean up hook docs
reidbarber Jun 11, 2026
caa94cb
Merge branch 'main' into new-hook-docs
reidbarber Jun 11, 2026
845d535
Merge branch 'main' into new-hook-docs
reidbarber Jun 22, 2026
addc70c
Merge remote-tracking branch 'origin/main' into new-hook-docs
reidbarber Jul 7, 2026
572300f
highlight hook usage in example code
reidbarber Jul 7, 2026
0c99759
move useDialog to useModalOverlay
reidbarber Jul 8, 2026
d05a588
add anatomy diagrams
reidbarber Jul 8, 2026
df9c44b
more highlighting hook usage
reidbarber Jul 8, 2026
c294d3d
migrate Listbox and GridList examples to new collections
reidbarber Jul 8, 2026
c80533a
fix Toast and Tooltip z-indexes
reidbarber Jul 8, 2026
14b4a36
update Calendar, RangeCalendar, and TagGroup to use RAC Button
reidbarber Jul 8, 2026
bdb5471
fix Calender/RangeCalender horizontal scrolling
reidbarber Jul 8, 2026
2d6d93f
group properties in interface table
reidbarber Jul 8, 2026
5223cfd
add FunctionAPIGroup for better styles for hook API section
reidbarber Jul 8, 2026
d82a571
Merge remote-tracking branch 'origin/main' into new-hook-docs
reidbarber Jul 8, 2026
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
highlight hook usage in example code
  • Loading branch information
reidbarber committed Jul 7, 2026
commit 572300fbaf6b1ccbc4e753a3be253ee6263034b7
2 changes: 2 additions & 0 deletions packages/dev/s2-docs/pages/react-aria/Popover/usePopover.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ function Popover({state, children, triggerRef, ...props}: Omit<Parameters<typeof
// usePopover positions the overlay relative to the trigger and closes it on
// outside interaction or Escape. The state comes from useOverlayTriggerState.
let popoverRef = React.useRef<HTMLDivElement>(null);
/*- begin highlight -*/
let {popoverProps, underlayProps} = usePopover({...props, triggerRef, popoverRef}, state);
/*- end highlight -*/

return (
// Overlay renders into a portal and contains focus while the popover is open.
Expand Down
2 changes: 2 additions & 0 deletions starters/hooks/src/Breadcrumbs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ export function Breadcrumbs(props: AriaBreadcrumbsProps & {children?: ReactNode}

export function Breadcrumb(props: AriaBreadcrumbItemProps & {href?: string; children?: ReactNode}) {
let ref = useRef<HTMLAnchorElement>(null);
/*- begin highlight -*/
let {itemProps} = useBreadcrumbItem({...props, elementType: 'a'}, ref);
/*- end highlight -*/
let {hoverProps, isHovered} = useHover(props);
let {focusProps, isFocusVisible} = useFocusRing();

Expand Down
2 changes: 2 additions & 0 deletions starters/hooks/src/Calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ import './Calendar.css';
export function Calendar(props: AriaCalendarProps<DateValue>) {
let {locale} = useLocale();
let state = useCalendarState({...props, locale, createCalendar});
/*- begin highlight -*/
let {calendarProps, prevButtonProps, nextButtonProps, title} = useCalendar(props, state);
/*- end highlight -*/

return (
<div {...calendarProps} className="react-aria-Calendar">
Expand Down
2 changes: 2 additions & 0 deletions starters/hooks/src/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ import './Checkbox.css';
export function Checkbox(props: AriaCheckboxProps) {
let state = useToggleState(props);
let ref = useRef<HTMLInputElement>(null);
/*- begin highlight -*/
let {inputProps, isSelected, isPressed, isDisabled, isReadOnly, isInvalid} = useCheckbox(
props,
state,
ref
);
/*- end highlight -*/
let {hoverProps, isHovered} = useHover({isDisabled: isDisabled || isReadOnly});
let {isFocused, isFocusVisible, focusProps} = useFocusRing();
let isIndeterminate = props.isIndeterminate || false;
Expand Down
2 changes: 2 additions & 0 deletions starters/hooks/src/CheckboxGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,13 @@ export function CheckboxGroup({children, orientation = 'vertical', ...props}: Ch
export function Checkbox(props: AriaCheckboxGroupItemProps) {
let state = React.useContext(CheckboxGroupContext)!;
let ref = useRef<HTMLInputElement>(null);
/*- begin highlight -*/
let {inputProps, isSelected, isPressed, isDisabled, isReadOnly, isInvalid} = useCheckboxGroupItem(
props,
state,
ref
);
/*- end highlight -*/
let {hoverProps, isHovered} = useHover({isDisabled: isDisabled || isReadOnly});
let {isFocused, isFocusVisible, focusProps} = useFocusRing();

Expand Down
3 changes: 2 additions & 1 deletion starters/hooks/src/ColorArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ export function ColorArea(props: AriaColorAreaProps) {
let containerRef = useRef<HTMLDivElement>(null);
// useColorAreaState manages the two channel values behind the 2D gradient.
let state = useColorAreaState(props);
// colorAreaProps.style carries the 2D gradient background, while thumbProps.style positions the thumb.
/*- begin highlight -*/
let {colorAreaProps, xInputProps, yInputProps, thumbProps} = useColorArea(
{...props, inputXRef, inputYRef, containerRef},
state
);
/*- end highlight -*/
let {focusProps, isFocusVisible} = useFocusRing();

return (
Expand Down
2 changes: 2 additions & 0 deletions starters/hooks/src/ColorField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import './Form.css';
export function ColorField(props: AriaColorFieldProps & {label?: React.ReactNode}) {
let state = useColorFieldState(props);
let inputRef = useRef<HTMLInputElement>(null);
/*- begin highlight -*/
let {labelProps, inputProps} = useColorField(props, state, inputRef);
/*- end highlight -*/
let [isFocused, setFocused] = useState(false);
let {focusProps} = useFocus({onFocusChange: setFocused});

Expand Down
3 changes: 2 additions & 1 deletion starters/hooks/src/ColorSlider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ export function ColorSlider(props: AriaColorSliderProps & {label?: string}) {

// Default the label to the channel name in the current locale.
let label = props.label || state.value.getChannelName(props.channel, locale);
// trackProps.style carries the gradient background, while thumbProps.style positions the thumb.
/*- begin highlight -*/
let {trackProps, thumbProps, inputProps, labelProps, outputProps} = useColorSlider(
{...props, label, trackRef, inputRef},
state
);
/*- end highlight -*/
let {focusProps, isFocusVisible} = useFocusRing();

return (
Expand Down
3 changes: 2 additions & 1 deletion starters/hooks/src/ColorWheel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ export function ColorWheel(props: Omit<AriaColorWheelProps, 'outerRadius' | 'inn
// useColorWheelState manages the hue value behind the circular gradient track.
let state = useColorWheelState(props);
let inputRef = useRef<HTMLInputElement>(null);
// trackProps.style carries the conic gradient, while thumbProps.style positions the thumb on the ring.
/*- begin highlight -*/
let {trackProps, thumbProps, inputProps} = useColorWheel(
{...props, outerRadius: RADIUS, innerRadius: RADIUS - TRACK_THICKNESS},
state,
inputRef
);
/*- end highlight -*/
let {focusProps, isFocusVisible} = useFocusRing();

return (
Expand Down
2 changes: 2 additions & 0 deletions starters/hooks/src/DateField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ export function DateField(props: AriaDateFieldProps<DateValue> & {label?: React.
let {locale} = useLocale();
let state = useDateFieldState({...props, locale, createCalendar});
let ref = useRef<HTMLDivElement>(null);
/*- begin highlight -*/
let {labelProps, fieldProps} = useDateField(props, state, ref);
/*- end highlight -*/
let [isFocusWithin, setFocusWithin] = useState(false);
let {focusWithinProps} = useFocusWithin({onFocusWithinChange: setFocusWithin});

Expand Down
2 changes: 2 additions & 0 deletions starters/hooks/src/Disclosure.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ export function Disclosure(props: AriaDisclosureProps & {title?: ReactNode; chil
let state = useDisclosureState(props);
let panelRef = useRef<HTMLDivElement>(null);
let buttonRef = useRef<HTMLButtonElement>(null);
/*- begin highlight -*/
let {buttonProps, panelProps} = useDisclosure(props, state, panelRef);
/*- end highlight -*/
let {buttonProps: pressProps, isPressed} = useButton(buttonProps, buttonRef);
let {hoverProps, isHovered} = useHover({});
let {focusProps, isFocusVisible} = useFocusRing();
Expand Down
2 changes: 2 additions & 0 deletions starters/hooks/src/Meter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import './Form.css';

export function Meter(props: AriaMeterProps) {
let {label, value = 0, minValue = 0, maxValue = 100} = props;
/*- begin highlight -*/
let {meterProps, labelProps} = useMeter(props);
/*- end highlight -*/

// Calculate the width of the meter fill as a percentage.
let percentage = ((value - minValue) / (maxValue - minValue)) * 100;
Expand Down
2 changes: 2 additions & 0 deletions starters/hooks/src/NumberField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ export function NumberField(props: AriaNumberFieldProps & {label?: React.ReactNo
let {locale} = useLocale();
let state = useNumberFieldState({...props, locale});
let inputRef = useRef<HTMLInputElement>(null);
/*- begin highlight -*/
let {labelProps, groupProps, inputProps, incrementButtonProps, decrementButtonProps} =
useNumberField(props, state, inputRef);
/*- end highlight -*/

return (
<div className="react-aria-NumberField">
Expand Down
2 changes: 2 additions & 0 deletions starters/hooks/src/ProgressBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import './Form.css';

export function ProgressBar(props: AriaProgressBarProps) {
let {label, value = 0, minValue = 0, maxValue = 100, isIndeterminate} = props;
/*- begin highlight -*/
let {progressBarProps, labelProps} = useProgressBar(props);
/*- end highlight -*/

// Calculate the width of the progress fill as a percentage.
let percentage = ((value - minValue) / (maxValue - minValue)) * 100;
Expand Down
2 changes: 2 additions & 0 deletions starters/hooks/src/RadioGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ export function RadioGroup({children, ...props}: RadioGroupProps) {
export function Radio(props: AriaRadioProps) {
let state = React.useContext(RadioContext)!;
let ref = useRef<HTMLInputElement>(null);
/*- begin highlight -*/
let {inputProps, isSelected, isPressed, isDisabled} = useRadio(props, state, ref);
/*- end highlight -*/
let {hoverProps, isHovered} = useHover({isDisabled: isDisabled || state.isReadOnly});
let {isFocused, isFocusVisible, focusProps} = useFocusRing();

Expand Down
2 changes: 2 additions & 0 deletions starters/hooks/src/RangeCalendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ export function RangeCalendar(props: AriaRangeCalendarProps<DateValue>) {
let {locale} = useLocale();
let state = useRangeCalendarState({...props, locale, createCalendar});
let ref = useRef<HTMLDivElement>(null);
/*- begin highlight -*/
let {calendarProps, prevButtonProps, nextButtonProps, title} = useRangeCalendar(
props,
state,
ref
);
/*- end highlight -*/

return (
<div {...calendarProps} ref={ref} className="react-aria-RangeCalendar">
Expand Down
2 changes: 2 additions & 0 deletions starters/hooks/src/SearchField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import './Form.css';
export function SearchField(props: AriaSearchFieldProps & {label?: React.ReactNode}) {
let state = useSearchFieldState(props);
let ref = useRef<HTMLInputElement>(null);
/*- begin highlight -*/
let {labelProps, inputProps, clearButtonProps} = useSearchField(props, state, ref);
/*- end highlight -*/
let [isFocused, setFocused] = useState(false);
let {focusProps} = useFocus({onFocusChange: setFocused});

Expand Down
2 changes: 2 additions & 0 deletions starters/hooks/src/Slider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ export function Slider({label, thumbLabels, fillOffset, formatOptions, ...props}
let trackRef = useRef<HTMLDivElement>(null);
let numberFormatter = useNumberFormatter(formatOptions);
let state = useSliderState({...props, numberFormatter});
/*- begin highlight -*/
let {groupProps, trackProps, labelProps, outputProps} = useSlider(props, state, trackRef);
/*- end highlight -*/

// The fill spans from fillOffset (or the min) to the last thumb.
let start =
Expand Down
2 changes: 2 additions & 0 deletions starters/hooks/src/Switch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ import './Switch.css';
export function Switch(props: AriaSwitchProps) {
let state = useToggleState(props);
let ref = useRef<HTMLInputElement>(null);
/*- begin highlight -*/
let {inputProps, isSelected, isPressed, isDisabled, isReadOnly, isInvalid} = useSwitch(
props,
state,
ref
);
/*- end highlight -*/
let {hoverProps, isHovered} = useHover({isDisabled: isDisabled || isReadOnly});
let {isFocused, isFocusVisible, focusProps} = useFocusRing();

Expand Down
2 changes: 2 additions & 0 deletions starters/hooks/src/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ function TableHeaderRow({
children: ReactNode;
}) {
let ref = useRef<HTMLTableRowElement>(null);
/*- begin highlight -*/
let {rowProps} = useTableHeaderRow({node: item}, state, ref);
/*- end highlight -*/
return (
<tr {...rowProps} ref={ref}>
{children}
Expand Down
2 changes: 2 additions & 0 deletions starters/hooks/src/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import './Tabs.css';
export function Tabs(props: AriaTabListOptions<object> & Parameters<typeof useTabListState>[0]) {
let state = useTabListState(props);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is also using old collections

let ref = useRef<HTMLDivElement>(null);
/*- begin highlight -*/
let {tabListProps} = useTabList(props, state, ref);
/*- end highlight -*/
let orientation = props.orientation || 'horizontal';

return (
Expand Down
2 changes: 2 additions & 0 deletions starters/hooks/src/TagGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ export function TagGroup(
) {
let ref = useRef<HTMLDivElement>(null);
let state = useListState(props);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should also use collectionbuilder

/*- begin highlight -*/
let {gridProps, labelProps} = useTagGroup(props, state, ref);
/*- end highlight -*/

return (
<div className="react-aria-TagGroup">
Expand Down
2 changes: 2 additions & 0 deletions starters/hooks/src/TextField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import './Form.css';

export function TextField(props: AriaTextFieldProps & {label?: React.ReactNode}) {
let ref = useRef<HTMLInputElement>(null);
/*- begin highlight -*/
let {labelProps, inputProps} = useTextField(props, ref);
/*- end highlight -*/
let [isFocused, setFocused] = useState(false);
let {focusProps} = useFocus({onFocusChange: setFocused});

Expand Down
2 changes: 2 additions & 0 deletions starters/hooks/src/TimeField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ export function TimeField(props: AriaTimeFieldProps<TimeValue> & {label?: React.
let {locale} = useLocale();
let state = useTimeFieldState({...props, locale});
let ref = useRef<HTMLDivElement>(null);
/*- begin highlight -*/
let {labelProps, fieldProps} = useTimeField(props, state, ref);
/*- end highlight -*/
let [isFocusWithin, setFocusWithin] = useState(false);
let {focusWithinProps} = useFocusWithin({onFocusWithinChange: setFocusWithin});

Expand Down
2 changes: 2 additions & 0 deletions starters/hooks/src/Toast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,13 @@ function Toast({
...props
}: AriaToastProps<string> & {state: ReturnType<typeof useToastState<string>>}) {
let ref = useRef<HTMLDivElement>(null);
/*- begin highlight -*/
let {toastProps, contentProps, titleProps, closeButtonProps} = useToast(
{...props, toast},
state,
ref
);
/*- end highlight -*/
let {focusProps, isFocusVisible} = useFocusRing();

return (
Expand Down
2 changes: 2 additions & 0 deletions starters/hooks/src/ToggleButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ interface ToggleButtonProps extends AriaToggleButtonProps {
export function ToggleButton({variant = 'primary', ...props}: ToggleButtonProps) {
let ref = useRef<HTMLButtonElement>(null);
let state = useToggleState(props);
/*- begin highlight -*/
let {buttonProps, isPressed} = useToggleButton(props, state, ref);
/*- end highlight -*/
let {hoverProps, isHovered} = useHover(props);
let {focusProps, isFocusVisible} = useFocusRing();

Expand Down
2 changes: 2 additions & 0 deletions starters/hooks/src/Toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import './Toolbar.css';
export function Toolbar(props: AriaToolbarProps & {children?: ReactNode}) {
let {orientation = 'horizontal'} = props;
let ref = useRef<HTMLDivElement>(null);
/*- begin highlight -*/
let {toolbarProps} = useToolbar(props, ref);
/*- end highlight -*/

return (
<div {...toolbarProps} ref={ref} className="react-aria-Toolbar" data-orientation={orientation}>
Expand Down