Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
closure-react-card
Advanced tools
A React version of an MDC Card.
npm install @material/react-card
with Sass:
import '@material/react-card/index.scss';
with CSS:
import '@material/react-card/dist/card.css';
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>
);
}
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
andstyle
.
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>
Prop Name | Type | Description |
---|---|---|
outlined | n/a | Enables an outline on the card. |
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>
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>
Prop Name | Type | Description |
---|---|---|
contentClassName | string | Adds a class to the .mdc-card__media-content element. |
square | n/a | Scales the height of the image to be equal to the width of the image. |
wide | n/a | Scales the height of the image maintaining a 16:9 aspect ratio. |
imageUrl | string | Path to the image of the <CardMedia> component. |
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>
Prop Name | Type | Description |
---|---|---|
fullBleed | n/a | Enables full bleed card actions row by removing all padding. |
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>
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 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.
Please see our Best Practices doc when importing or using icon fonts.
FAQs
Material Components React Card
The npm package closure-react-card receives a total of 2 weekly downloads. As such, closure-react-card popularity was classified as not popular.
We found that closure-react-card demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.