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

Function TabsInner

packages/react-aria-components/src/Tabs.tsx:285–327  ·  view source on GitHub ↗
({props, tabsRef: ref, collection}: TabsInnerProps)

Source from the content-addressed store, hash-verified

283// Renders tabs from a collection that has already been built, so that a component that builds the
284// collection itself (e.g. Wizard) doesn't build it again.
285export function TabsInner({props, tabsRef: ref, collection}: TabsInnerProps): JSX.Element {
286 let {orientation = 'horizontal'} = props;
287 let state = useTabListState({
288 ...props,
289 collection,
290 children: undefined
291 });
292 let {focusProps, isFocused, isFocusVisible} = useFocusRing({within: true});
293 let values = useMemo(
294 () => ({
295 orientation,
296 isFocusWithin: isFocused,
297 isFocusVisible
298 }),
299 [orientation, isFocused, isFocusVisible]
300 );
301 let renderProps = useRenderProps({
302 ...props,
303 defaultClassName: 'react-aria-Tabs',
304 values
305 });
306
307 let DOMProps = filterDOMProps(props, {global: true});
308
309 return (
310 <dom.div
311 {...mergeProps(DOMProps, renderProps, focusProps)}
312 ref={ref}
313 slot={props.slot || undefined}
314 data-focused={isFocused || undefined}
315 data-orientation={orientation}
316 data-focus-visible={isFocusVisible || undefined}
317 data-disabled={state.isDisabled || undefined}>
318 <Provider
319 values={[
320 [TabsContext, props],
321 [TabListStateContext, state]
322 ]}>
323 {renderProps.children}
324 </Provider>
325 </dom.div>
326 );
327}
328
329/**
330 * A TabList is used within Tabs to group tabs that a user can switch between. The ids of the items

Callers

nothing calls this directly

Calls 5

useTabListStateFunction · 0.90
useFocusRingFunction · 0.90
useRenderPropsFunction · 0.90
filterDOMPropsFunction · 0.90
mergePropsFunction · 0.90

Tested by

no test coverage detected