Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

abaabil.details

Package Overview
Dependencies
Maintainers
0
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

abaabil.details

  • 0.0.24
  • unpublished
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
0
Weekly downloads
 
Created
Source

Details Component

npm version npm downloads

The Details component is a versatile and customizable expandable section built with React. It supports different variants, sizes, and icons, making it suitable for a wide range of use cases.

Overview

The Details component is used to create expandable sections in your application. This documentation provides instructions on how to use the Details component in your JSX-based projects. The Details component is a part of the abaabil.details library.

Importing the Details Component

You can import the Details component from the abaabil package or directly from the abaabil.details package.

import { Details } from 'abaabil';
// or
import Details from 'abaabil.details';

Usage Example

The Details component can be used in your JSX to create expandable sections with various properties. You can customize the component by setting its properties such as summary, icon, variant, size, and more.

import * as React from 'react';
import Details from 'abaabil.details';

const App = () => (
  <div>
    <Details summary="Primary Details" variant="primary">
      <p>This is the primary details content.</p>
    </Details>
    <Details summary="Secondary Details" variant="secondary" size="sp" icon="info">
      <p>This is the secondary details content.</p>
    </Details>
    <Details summary="Tertiary Details" variant="tertiary" size="cp" openIcon="plus" closeIcon="minus">
      <p>This is the tertiary details content.</p>
    </Details>
    <Details summary="Success Details" variant="success" expanded>
      <p>This is the success details content.</p>
    </Details>
    <Details summary="Error Details" variant="error" size="df" icon="warning">
      <p>This is the error details content.</p>
    </Details>
  </div>
);

export default App;

More Usage Examples

Normal Variants
import * as React from 'react';
import Details from 'abaabil.details';

const Example = () => (
  <div className="flex flex-col gap-4">
    <Details variant="primary" summary="Primary">Primary content</Details>
    <Details variant="secondary" summary="Secondary">Secondary content</Details>
    <Details variant="tertiary" summary="Tertiary">Tertiary content</Details>
    <Details variant="success" summary="Success">Success content</Details>
    <Details variant="error" summary="Error">Error content</Details>
  </div>
);

export default Example;
Outlined Variants
import * as React from 'react';
import Details from 'abaabil.details';

const Example = () => (
  <div className="flex flex-col gap-4">
    <Details variant="primary" icon="apple" summary="Primary" outlined>Primary content</Details>
    <Details variant="secondary" icon="cherry" summary="Secondary" outlined>Secondary content</Details>
    <Details variant="tertiary" icon="lemon" summary="Tertiary" outlined>Tertiary content</Details>
    <Details variant="success" icon="carrot" summary="Success" outlined>Success content</Details>
    <Details variant="error" icon="mushroom" summary="Error" outlined>Error content</Details>
  </div>
);

export default Example;
Sizes
import * as React from 'react';
import Details from 'abaabil.details';

const Example = () => (
  <div className="divide-y divide-layer-dark-1 space-y-4">
    <div>
      <Details size="cp" summary="Small">Small content</Details>
    </div>
    <div className="pt-4">
      <Details summary="Base">Base content</Details>
    </div>
    <div className="pt-4">
      <Details size="sp" summary="Large">Large content</Details>
    </div>
  </div>
);

export default Example;

Props

PropTypeDefaultDescription
summarystring''The summary text to display in the details summary.
childrennodenullThe content to display inside the details section.
variantstringprimaryThe details variant. Can be primary, secondary, tertiary, success, or error.
sizestringdfThe size of the details. Can be cp, df, or sp.
iconstringnullIcon to display in the summary. Uses the Icon component.
openIconstringchevron-downIcon to display when the details are closed. Uses the Icon component.
closeIconstringchevron-upIcon to display when the details are open. Uses the Icon component.
expandedbooleanfalseWhether the details should be expanded by default.
outlinedbooleanfalseWhether the details should be outlined.
...propsobject{}Additional props to pass to the details element.

Variants

  • primary: Default details style with primary background and text.
  • secondary: Secondary details style with secondary background and text.
  • tertiary: Tertiary details style with tertiary background and text.
  • success: Success details style with success background and text.
  • error: Error details style with error background and text.

Sizes

  • cp: Small details size.
  • df: Base details size.
  • sp: Large details size.

Example

import * as React from 'react';
import Details from 'abaabil.details';

const Example = () => (
  <div>
    <Details summary="Primary Details" variant="primary">
      <p>This is the primary details content.</p>
    </Details>
    <Details summary="Secondary Details" variant="secondary" size="sp" icon="info">
      <p>This is the secondary details content.</p>
    </Details>
    <Details summary="Tertiary Details" variant="tertiary" size="cp" openIcon="plus" closeIcon="minus">
      <p>This is the tertiary details content.</p>
    </Details>
    <Details summary="Success Details" variant="success" expanded>
      <p>This is the success details content.</p>
    </Details>
    <Details summary="Error Details" variant="error" size="df" icon="warning">
      <p>This is the error details content.</p>
    </Details>
  </div>
);

export default Example;

Accessibility

The Details component is designed with accessibility in mind:

  • It uses proper ARIA attributes for the summary and content.
  • Keyboard navigation is supported (Enter and Space keys to toggle).
  • The component manages its own open/closed state.
  • The summary and content are properly labeled for screen readers.

Keywords

FAQs

Package last updated on 11 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc