Inline List
tetra-ui/inline-listFreeComponent
A grouped list section for settings-style rows with flexible leading and trailing addons.
Live preview
live · rendered by the registry
Rendered by tetra-ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://tetra-ui.com/r/inline-list.jsonSource
1import { cva, type VariantProps } from "class-variance-authority";2import {3 Children,4 cloneElement,5 createContext,6 isValidElement,7 useContext,8 useMemo,9} from "react";10import { Pressable, View } from "react-native";11import { cn } from "@/lib/utils";12import { Text } from "./text";1314// Types15export type InlineListProps = React.ComponentProps<typeof View> & {16 title?: string;17 children: React.ReactNode;18};1920type InlineListItemVariant = "default" | "destructive";2122export type InlineListItemProps = React.ComponentProps<typeof Pressable> & {23 children: React.ReactNode;24 showSeparator?: boolean;25 variant?: InlineListItemVariant;26};2728export type InlineListItemTitleProps = React.ComponentProps<typeof Text>;29export type InlineListItemDescriptionProps = React.ComponentProps<typeof Text>;3031export type InlineListItemAddonProps = React.ComponentProps<typeof View> &32 VariantProps<typeof inlineListItemAddonVariants> & {33 children: React.ReactNode;34 };3536type InlineListItemAddonIconProps = {37 children: React.ReactNode;38 className?: string;39};4041export type InlineListItemAddonChild =42 | React.ReactElement<InlineListItemAddonProps>43 | null44 | false;4546export type InlineListItemAddonChildren =47 | InlineListItemAddonChild48 | InlineListItemAddonChild[];4950type InlineListItemAddonAlign = NonNullable<51 VariantProps<typeof inlineListItemAddonVariants>["align"]52>;5354// Context55type InlineListSeparatorContextValue = {56 showSeparator: boolean;57};5859const InlineListSeparatorContext =60 createContext<InlineListSeparatorContextValue | null>(null);6162const InlineListItemContext = createContext<InlineListItemVariant>("default");6364const useInlineListItemContext = () => useContext(InlineListItemContext);6566const InlineListItemAddonContext =67 createContext<InlineListItemAddonAlign>("inline-start");6869const useInlineListItemAddonContext = () =>70 useContext(InlineListItemAddonContext);7172// Hooks73export const useInlineListItemAddons = (children?: React.ReactNode) => {74 const startAddons: InlineListItemAddonChild[] = [];75 const endAddons: InlineListItemAddonChild[] = [];7677 Children.forEach(children, (child) => {78 if (isValidElement(child) && child.type === InlineListItemAddon) {79 const typedChild = child as InlineListItemAddonChild;8081 if (typedChild) {82 if (83 typeof typedChild.props.align === "undefined" ||84 typedChild.props.align === "inline-start"85 ) {86 startAddons.push(typedChild);87 } else {88// … truncated
Files it writes
More from tetra-ui
All 41 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | tetra-ui | Components | Free | 1 dep | |
| Action Inputaction-input | tetra-ui | Components | Free | no deps | |
| Alertalert | tetra-ui | Components | Free | no deps | |
| Avataravatar | tetra-ui | Components | Free | no deps | |
| Badgebadge | tetra-ui | Components | Free | no deps | |
| Bottom Sheetbottom-sheet | tetra-ui | Components | Free | 4 deps · 7 files | |
| Buttonbutton | tetra-ui | Components | Free | no deps | |
| Cardcard | tetra-ui | Components | Free | no deps |
