aspect-ratio
shadcn-solidjs/aspect-ratioFreeComponent
shadcn-solidjs publishes no description for this item.
Live preview
live · rendered by the registry
Rendered by shadcn-solidjs on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://shadcn-solidjs.com/r/aspect-ratio.jsonSource
1import type { Component, ComponentProps, JSX } from "solid-js";2import { mergeProps, splitProps } from "solid-js";34type AspectRatioProps = ComponentProps<"div"> & { ratio?: number };56const AspectRatio: Component<AspectRatioProps> = (rawProps) => {7 const props = mergeProps({ ratio: 1 / 1 }, rawProps);8 const [local, others] = splitProps(props, ["ratio", "style"]);9 const style = (): JSX.CSSProperties => ({10 ...(typeof local.style === "object" ? local.style : {}),11 position: "absolute",12 top: 0,13 right: 0,14 bottom: 0,15 left: 0,16 });17 return (18 <div19 style={{20 position: "relative",21 width: "100%",22 "padding-bottom": `${100 / local.ratio}%`,23 }}24 >25 <div data-slot="aspect-ratio" style={style()} {...others} />26 </div>27 );28};2930export { AspectRatio };
More from shadcn-solidjs
All 85 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| accordionaccordion | shadcn-solidjs | Components | Free | 1 dep | |
| alertalert | shadcn-solidjs | Components | Free | 2 deps | |
| alert-dialogalert-dialog | shadcn-solidjs | Components | Free | 2 deps | |
| attachmentattachment | shadcn-solidjs | Components | Free | 2 deps | |
| avataravatar | shadcn-solidjs | Components | Free | 1 dep | |
| badgebadge | shadcn-solidjs | Components | Free | 2 deps | |
| breadcrumbbreadcrumb | shadcn-solidjs | Components | Free | 1 dep | |
| bubblebubble | shadcn-solidjs | Components | Free | 2 deps |
