Skip to content
Gravity Logo / Docs Gravity home
Browse documentation
Documentation/Gravity Web

Card

The Card component displays a card with a header, content, and footer. It provides an organized way to present information with optional loading states and alignment features.

Usage

import { Card } from 'components/lib';

function MyComponent({ ...props }){

  return (
    <Card title='Card Title' description='Card Description'>
      Card content goes here.
    </Card>
  );
}

Props

PropDescriptionRequiredValue
centeralign the card in the center of it’s parentoptionalboolean
childrenchildren to renderrequiredcomponent(s)
classNamecustom styleoptionalSCSS or Tailwind
descriptionheader descriptionoptionalstring
loadingtoggle the loading spinneroptionalboolean
titleheader titleoptionalstring

Example

import { Card, Table, useAPI } from 'components/lib';

function Example({ ...props }){

 const { data, loading } = useAPI('/api/account/users');

  return (
    <div>
      <Card title='Card Title' description='Card Description' loading={ loading }>
        <Table data={ data?.users || [] }/>
      </Card>
    </div>
  );
}

Notes

  • The Card component uses cn and Loader from 'components/lib'.
  • The center prop aligns the card in the center of its parent.
  • The loading prop toggles a loading animation.
  • The children prop can include a React component(s) or CardHeader, CardContent, and CardFooter components.
  • For more details, refer to the Shadcn Card documentation.