Flex
solid-ui/flexFreeComponent
A flex component
Live preview
live · rendered by the registry
Rendered by solid-ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://www.solid-ui.com/r/flex.jsonSource
1import type { Component, ComponentProps } from "solid-js"2import { mergeProps, splitProps } from "solid-js"34import { cn } from "~/lib/utils"56type JustifyContent = "start" | "end" | "center" | "between" | "around" | "evenly"7type AlignItems = "start" | "end" | "center" | "baseline" | "stretch"8type FlexDirection = "row" | "col" | "row-reverse" | "col-reverse"910type FlexProps = ComponentProps<"div"> & {11 flexDirection?: FlexDirection12 justifyContent?: JustifyContent13 alignItems?: AlignItems14}1516const Flex: Component<FlexProps> = (rawProps) => {17 const props = mergeProps(18 {19 flexDirection: "row",20 justifyContent: "between",21 alignItems: "center"22 } satisfies FlexProps,23 rawProps24 )25 const [local, others] = splitProps(props, [26 "flexDirection",27 "justifyContent",28 "alignItems",29 "class"30 ])3132 return (33 <div34 class={cn(35 "flex w-full",36 flexDirectionClassNames[local.flexDirection],37 justifyContentClassNames[local.justifyContent],38 alignItemsClassNames[local.alignItems],39 local.class40 )}41 {...others}42 />43 )44}4546export { Flex }4748const justifyContentClassNames: { [key in JustifyContent]: string } = {49 start: "justify-start",50 end: "justify-end",51 center: "justify-center",52 between: "justify-between",53 around: "justify-around",54 evenly: "justify-evenly"55}5657const alignItemsClassNames: { [key in AlignItems]: string } = {58 start: "items-start",59 end: "items-end",60 center: "items-center",61 baseline: "items-baseline",62 stretch: "items-stretch"63}6465const flexDirectionClassNames: { [key in FlexDirection]: string } = {66 row: "flex-row",67 col: "flex-col",68 "row-reverse": "flex-row-reverse",69 "col-reverse": "flex-col-reverse"70}
What it pulls in
npm packages
Files it writes
More from solid-ui
All 55 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | solid-ui | Components | Free | 2 deps | |
| Alertalert | solid-ui | Components | Free | 3 deps | |
| Alert Dialogalert-dialog | solid-ui | Components | Free | 2 deps | |
| Aspect Ratioaspect-ratio | solid-ui | Components | Free | 1 dep | |
| Avataravatar | solid-ui | Components | Free | 2 deps | |
| Badgebadge | solid-ui | Components | Free | 2 deps | |
| Badge Deltabadge-delta | solid-ui | Components | Free | 2 deps | |
| Bar Listbar-list | solid-ui | Components | Free | 1 dep |
