Aspect Ratio
nswds-ui/aspect-ratioFreeComponent
Constrains its content to a given width-to-height ratio.
Install it
npx shadcn@latest add https://raw.githubusercontent.com/digitalnsw/nswds-ui/main/apps/registry/public/r/aspect-ratio.jsonSource
1import * as React from 'react'23import { cn } from '@/lib/utils'45function AspectRatio({6 ratio,7 className,8 ...props9}: React.ComponentProps<'div'> & { ratio: number }) {10 return (11 <div12 data-slot='aspect-ratio'13 style={14 {15 '--ratio': ratio,16 } as React.CSSProperties17 }18 className={cn('relative aspect-(--ratio)', className)}19 {...props}20 />21 )22}2324export { AspectRatio }
What it pulls in
npm packages
Other registry items
Files it writes
More from @nswds/ui
All 46 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Badgebadge | @nswds/ui | Components | Free | 4 deps · 2 files | |
| Buttonbutton | @nswds/ui | Components | Free | 4 deps · 2 files | |
| Cardcard | @nswds/ui | Components | Free | 2 deps · 2 files | |
| Collapsiblecollapsible | @nswds/ui | Components | Free | 1 dep | |
| Drawerdrawer | @nswds/ui | Components | Free | 3 deps · 2 files | |
| Expandable Searchexpandable-search | @nswds/ui | Components | Free | 3 deps · 2 files | |
| Fieldfield | @nswds/ui | Components | Free | 4 deps · 2 files | |
| Footerfooter | @nswds/ui | Components | Free | 3 deps · 2 files |
