Icon

Symbols / images using Material icons with customizable colors and sizes.

Props:

PropertiesDescriptionsRequiredDefault

color

The color of the component.

Color.Black

disabled

If true, the component is no longer interactive and is greyed out.

false

name

The name of the Google Fonts Material Icon to be rendered. List of supported icons: HERE

onClick

Callback function that executes when the component is clicked.

size

Size of the icon to be rendered.

IconSize.Medium

tooltip

Text that appears when hovering over the component.

variant

The default look is for icons to be filled. This can be overridden with: IconVariant.Outlined IconVariant.Round IconVariant.Sharp IconVariant.TwoTone

Examples

import { whisper } from '@oliveai/ldk';
import {
  Color,
  Direction,
  IconSize,
  IconVariant,
  JustifyContent,
  StyleSize,
  WhisperComponentType,
} from '@oliveai/ldk/dist/whisper/types';

whisper.create({
  label: 'Icon Example',
  components: [
    {
      type: whisper.WhisperComponentType.Box,
      direction: Direction.Vertical,
      justifyContent: JustifyContent.Left,
      children: [
        {
          type: whisper.WhisperComponentType.Markdown,
          body: 'Icon utilizes different Material Icons.',
        },
        {
          type: whisper.WhisperComponentType.Box,
          direction: Direction.Horizontal,
          justifyContent: JustifyContent.Left,
          children: [
            {
              type: whisper.WhisperComponentType.Icon,
              name: 'star',
            },
            {
              type: whisper.WhisperComponentType.Icon,
              name: 'arrow_forward',
            },
            {
              type: whisper.WhisperComponentType.Icon,
              name: 'disc_full',
            },
            {
              type: whisper.WhisperComponentType.Icon,
              name: 'edit',
            },
            {
              type: whisper.WhisperComponentType.Icon,
              name: 'home',
            },
          ],
        },
        {
          type: whisper.WhisperComponentType.Divider,
          layout: {
            marginBottom: StyleSize.Small,
            marginTop: StyleSize.Small,
          },
        },
        {
          type: whisper.WhisperComponentType.Markdown,
          body: 'Icon with a click handler or disabled, and have a tooltip.',
        },
        {
          type: whisper.WhisperComponentType.Box,
          direction: Direction.Horizontal,
          justifyContent: JustifyContent.Left,
          children: [
            {
              type: whisper.WhisperComponentType.Icon,
              name: 'arrow_forward',
              onClick: () => console.log('Clicked Active'),
            },
            {
              type: whisper.WhisperComponentType.Icon,
              disabled: true,
              name: 'arrow_forward',
              onClick: () => console.log('Clicked Disabled'),
            },
          ],
        },
        {
          type: whisper.WhisperComponentType.Divider,
          layout: {
            marginBottom: StyleSize.Small,
            marginTop: StyleSize.Small,
          },
        },
        {
          type: whisper.WhisperComponentType.Markdown,
          body: 'Icons with different sizes.',
        },
        {
          type: whisper.WhisperComponentType.Box,
          direction: Direction.Horizontal,
          justifyContent: JustifyContent.Left,
          children: [
            {
              type: whisper.WhisperComponentType.Icon,
              name: 'add_circle',
              size: IconSize.Small,
            },
            {
              type: whisper.WhisperComponentType.Icon,
              name: 'add_circle',
              size: IconSize.Medium,
            },
            {
              type: whisper.WhisperComponentType.Icon,
              name: 'add_circle',
              size: IconSize.Large,
            },
            {
              type: whisper.WhisperComponentType.Icon,
              name: 'add_circle',
              size: IconSize.XLarge,
            },
          ],
        },
        {
          type: whisper.WhisperComponentType.Divider,
          layout: {
            marginBottom: StyleSize.Small,
            marginTop: StyleSize.Small,
          },
        },
        {
          type: whisper.WhisperComponentType.Markdown,
          body: 'Icons with different colors.',
        },
        {
          type: whisper.WhisperComponentType.Box,
          direction: Direction.Horizontal,
          justifyContent: JustifyContent.Left,
          children: [
            {
              type: whisper.WhisperComponentType.Icon,
              name: 'add_location',
              color: Color.Black,
            },
            {
              type: whisper.WhisperComponentType.Icon,
              name: 'add_location',
              color: Color.Accent,
            },
            {
              type: whisper.WhisperComponentType.Icon,
              name: 'add_location',
              color: Color.Grey,
            },
            {
              type: whisper.WhisperComponentType.Icon,
              name: 'add_location',
              color: Color.WhisperStrip,
            },
            {
              type: whisper.WhisperComponentType.Icon,
              name: 'add_location',
              color: Color.White,
            },
          ],
        },
        {
          type: whisper.WhisperComponentType.Divider,
          layout: {
            marginBottom: StyleSize.Small,
            marginTop: StyleSize.Small,
          },
        },
        {
          type: whisper.WhisperComponentType.Markdown,
          body: 'Different Icon variants.',
        },
        {
          type: whisper.WhisperComponentType.Box,
          direction: Direction.Horizontal,
          justifyContent: JustifyContent.Left,
          children: [
            {
              type: whisper.WhisperComponentType.Icon,
              name: 'account_balance_wallet',
            },
            {
              type: whisper.WhisperComponentType.Icon,
              name: 'account_balance_wallet',
              variant: IconVariant.Outlined,
            },
            {
              type: whisper.WhisperComponentType.Icon,
              name: 'account_balance_wallet',
              variant: IconVariant.Round,
            },
            {
              type: whisper.WhisperComponentType.Icon,
              name: 'account_balance_wallet',
              variant: IconVariant.Sharp,
            },
            {
              type: whisper.WhisperComponentType.Icon,
              name: 'account_balance_wallet',
              variant: IconVariant.TwoTone,
            },
          ],
        },
        {
          type: whisper.WhisperComponentType.Divider,
          layout: {
            marginBottom: StyleSize.Small,
            marginTop: StyleSize.Small,
          },
        },
      ],
    },
  ],
});

Last updated