Aspect Ratio

PreviousNext
Docs
skyrblock

Preview

Loading preview…
components/aspect-ratio/AspectRatio.tsx
'use client';

import type { ComponentRef } from 'react';
import { forwardRef } from 'react';
import type { Root } from '@radix-ui/react-aspect-ratio';
import { useComponentConfig } from '../config-provider/context';
import AspectRatioUI from './AspectRatioUI';
import type { AspectRatioProps } from './types';

const AspectRatio = forwardRef<ComponentRef<typeof Root>, AspectRatioProps>((props, ref) => {
  const config = useComponentConfig('aspectRatio');

  const mergedProps = {
    ...config,
    ...props
  };

  return (
    <AspectRatioUI
      {...mergedProps}
      ref={ref}
    />
  );
});

AspectRatio.displayName = 'AspectRatio';

export default AspectRatio;

Installation

npx shadcn@latest add @skyr/aspect-ratio

Usage

import { AspectRatio } from "@/components/aspect-ratio"
<AspectRatio />