Socket
Socket
Sign inDemoInstall

closure-react-card

Package Overview
Dependencies
16
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    closure-react-card

Material Components React Card


Version published
Maintainers
1
Install size
1.48 MB
Created

Readme

Source

React Card

A React version of an MDC Card.

Installation

npm install @material/react-card

Usage

Syles

with Sass:

import '@material/react-card/index.scss';

with CSS:

import '@material/react-card/dist/card.css';

Javascript Instantiation

import React from 'react';
import Card, {
  CardPrimaryContent,
  CardMedia,
  CardActions,
  CardActionButtons,
  CardActionIcons
} from "@material/react-card";

const MyApp = () => {
  return (
    <Card>
      <CardPrimaryContent>
        <h1>Header</h1>
        <CardMedia imageUrl='./my/fancy/image.png' />
      </CardPrimaryContent>

      <CardActions>
        <CardActionButtons>
          <button>Click Me</button>
        </CardActionButtons>

        <CardActionIcons>
          <i>Click Me Too!</i>
        </CardActionIcons>
      </CardActions>
    </Card>
  );
}

Components

The following components are MDC Card components. Other components outside of this package also can be used with these components, since there is such a large variety of card types. For further descriptions, please refer to MDC Card.

NOTE: All following components will still pass through the props className and style.

Card

This is the container component for the entire card. All other components listed in this documentation should be a child to this component.

import Card from '@material/react-card';

<Card>
  <h1>Title</h1>
  <p>Content</p>
</Card>
Props
Prop NameTypeDescription
outlinedn/aEnables an outline on the card.

CardPrimaryContent

This component is used as the container for primary tappable content.

import Card, {CardPrimaryContent} from '@material/react-card';

<Card>
  <CardPrimaryContent>
    <p>Content</p>
  </CardPrimaryContent>
</Card>

CardMedia

This component is a container for an image on the card. Optionally, any children of the <CardMedia> component is wrapped with an element with the className .mdc-card__media-content.

import {CardMedia} from '@material/react-card';

<CardMedia imageUrl='./my/fancy/image.png'>
  <span>Fancy Image</span>
</CardMedia>
Props
Prop NameTypeDescription
contentClassNamestringAdds a class to the .mdc-card__media-content element.
squaren/aScales the height of the image to be equal to the width of the image.
widen/aScales the height of the image maintaining a 16:9 aspect ratio.
imageUrlstringPath to the image of the <CardMedia> component.

CardActions

Acts as a container for <CardActionButtons> and/or <CardActionIcons>. It should be used as the last child of the <Card> component.

import {CardActions, CardActionButtons, CardActionIcons} from '@material/react-card';

<CardActions>
  <CardActionButtons> ... </CardActionButtons>
  <CardActionIcons> ... </CardActionIcons>
</CardActions>
Props
Prop NameTypeDescription
fullBleedn/aEnables full bleed card actions row by removing all padding.

CardActionButtons

It acts as a container for buttons of the card. This component is a child of a <CardActions> component.

import {CardActionButtons} from '@material/react-card';

<CardActionButtons>
  <button onClick={ ... }>Action 1</button>
  <button onClick={ ... }>Action 2</button>
</CardActionButtons>

CardActionIcons

It acts as a container for icons of the card. This component is a child of a <CardActions> component. It can be used by itself or used as a sibling directly after the <CardActionButtons> component.

import {CardActionIcons} from '@material/react-card';

<CardActionIcons>
  <i onClick={ ... }>Icon 1</i>
  <i onClick={ ... }>Icon 2</i>
</CardActionIcons>

Sass Mixins

Sass mixins may be available to customize various aspects of the Components. Please refer to the MDC Web repository for more information on what mixins are available, and how to use them.

Advanced Sass Mixins

Usage with Icons

Please see our Best Practices doc when importing or using icon fonts.

Keywords

FAQs

Last updated on 26 Dec 2018

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc