MCPcopy Create free account
hub / github.com/adobe/react-spectrum / Option

Function Option

packages/react-aria/stories/select/example.tsx:121–152  ·  view source on GitHub ↗
({item, state})

Source from the content-addressed store, hash-verified

119}
120
121function Option({item, state}) {
122 let ref = React.useRef(null);
123 let {optionProps, isSelected, isFocused, isDisabled} = useOption({key: item.key}, state, ref);
124
125 let backgroundColor;
126 let color = 'black';
127
128 if (isSelected) {
129 backgroundColor = 'blueviolet';
130 color = 'white';
131 } else if (isFocused) {
132 backgroundColor = 'gray';
133 } else if (isDisabled) {
134 backgroundColor = 'transparent';
135 color = 'gray';
136 }
137
138 return (
139 <li
140 {...optionProps}
141 ref={ref}
142 style={{
143 background: backgroundColor,
144 color: color,
145 padding: '2px 5px',
146 outline: 'none',
147 cursor: 'pointer'
148 }}>
149 {item.rendered}
150 </li>
151 );
152}

Callers

nothing calls this directly

Calls 1

useOptionFunction · 0.90

Tested by

no test coverage detected