14.3.5 • Published 23 days ago

@rmwc/card v14.3.5

Weekly downloads
4,602
License
MIT
Repository
github
Last release
23 days ago

Cards

Cards contain content and actions about a single subject.

  • Module @rmwc/card
  • Import styles:
    • Using CSS Loader
      • import '@rmwc/card/styles';
    • Or include stylesheets
      • '@material/card/dist/mdc.card.css'
      • '@material/button/dist/mdc.button.css'
      • '@material/icon-button/dist/mdc.icon-button.css'
  • MDC Docs: https://material.io/develop/web/components/cards/

Fully Featured Example

<Card style={{ width: '21rem' }}>
  <CardPrimaryAction>
    <CardMedia
      sixteenByNine
      style={{
        backgroundImage: 'url(images/backgrounds/mb-bg-fb-16.png)'
      }}
    />
    <div style={{ padding: '0 1rem 1rem 1rem' }}>
      <Typography use="headline6" tag="h2">
        Our Changing Planet
      </Typography>
      <Typography
        use="subtitle2"
        tag="h3"
        theme="textSecondaryOnBackground"
        style={{ marginTop: '-1rem' }}
      >
        by Kurt Wagner
      </Typography>
      <Typography
        use="body1"
        tag="div"
        theme="textSecondaryOnBackground"
      >
        Visit ten places on our planet that are undergoing the biggest
        changes today.
      </Typography>
    </div>
  </CardPrimaryAction>
  <CardActions>
    <CardActionButtons>
      <CardActionButton>Read</CardActionButton>
      <CardActionButton>Bookmark</CardActionButton>
    </CardActionButtons>
    <CardActionIcons>
      <CardActionIcon onIcon="favorite" icon="favorite_border" />
      <CardActionIcon icon="share" />
      <CardActionIcon icon="more_vert" />
    </CardActionIcons>
  </CardActions>
</Card>

Article Preview Example

<Card outlined style={{ width: '21rem' }}>
  <Typography
    use="subtitle1"
    tag="div"
    style={{ padding: '0.5rem 1rem' }}
    theme="textSecondaryOnBackground"
  >
    Headlines
  </Typography>

  <ListDivider />

  <CardPrimaryAction>
    <div style={{ padding: '1rem' }}>
      <Typography use="headline5" tag="div">
        Copper on the rise
      </Typography>
      <Typography use="body1" tag="p" theme="textSecondaryOnBackground">
        Copper price soars amid global market optimism and increased
        demand.
      </Typography>
    </div>
  </CardPrimaryAction>

  <ListDivider />

  <CardPrimaryAction>
    <div style={{ padding: '1rem' }}>
      <Typography use="headline5" tag="div">
        U.S. tech startups rebound
      </Typography>
      <Typography use="body1" tag="p" theme="textSecondaryOnBackground">
        Favorable business conditions have allowed startups to secure
        more fundraising deals compared to last year.
      </Typography>
    </div>
  </CardPrimaryAction>

  <ListDivider />

  <CardPrimaryAction>
    <div style={{ padding: '1rem' }}>
      <Typography use="headline5" tag="div">
        Asia's clean energy ambitions
      </Typography>
      <Typography use="body1" tag="p" theme="textSecondaryOnBackground">
        China plans to invest billions of dollars for the development of
        over 300 clean energy projects in Southeast Asia.
      </Typography>
    </div>
  </CardPrimaryAction>

  <ListDivider />

  <CardActions fullBleed>
    <CardActionButton
      label="All Business Headlines"
      trailingIcon="arrow_forward"
    />
  </CardActions>
</Card>

Mini Card Example

<Card style={{ width: '12.5rem' }}>
  <CardPrimaryAction>
    <CardMedia
      square
      style={{
        backgroundImage: 'url(images/backgrounds/mb-bg-fb-06.png)'
      }}
    >
      <CardMediaContent>
        <Typography
          use="subtitle2"
          tag="div"
          theme="textPrimaryOnDark"
          style={{
            padding: '0.5rem 1rem',
            backgroundImage:
              'linear-gradient(to bottom, transparent 0%, rgba(0, 0, 0, 0.5) 100%)',
            bottom: '0',
            left: '0',
            right: '0',
            position: 'absolute'
          }}
        >
          Vacation Photos
        </Typography>
      </CardMediaContent>
    </CardMedia>
  </CardPrimaryAction>
  <CardActions>
    <CardActionIcons>
      <CardActionIcon onIcon="favorite" icon="favorite_border" />
      <CardActionIcon icon="bookmark_border" />
      <CardActionIcon icon="share" />
    </CardActionIcons>
  </CardActions>
</Card>

Card

A Card Component

Props

NameTypeDescription
outlinedbooleanRemoves the shadow and displays a hairline outline instead

CardPrimaryAction

The main clickable area for the primary content of the card

CardMedia

Media area that displays a custom background-image with background-size: cover

Props

NameTypeDescription
sixteenByNinebooleanAutomatically scales the media area’s height according to its width, maintaining a 16:9 aspect ratio
squarebooleanAutomatically scales the media area’s height to equal its width

CardMediaContent

An absolutely-positioned box the same size as the media area, for displaying a title or icon on top of the background-image

CardActions

Row containing action buttons and/or icons

Props

NameTypeDescription
fullBleedbooleanRemoves the action area’s padding and causes its only child (an mdc-card__action element) to consume 100% of the action area’s width

CardActionButtons

A group of action buttons, displayed on the left side of the card (in LTR), adjacent to CardActionIcons

CardActionIcons

A group of supplemental action icons, displayed on the right side of the card (in LTR), adjacent to CardActionButtons

CardActionIcon

A card action Icon

Props

NameTypeDescription
checkedbooleanControls the on / off state of the a toggleable button.
disabledbooleanMakes the button disabled
foundationRefRef<MDCIconButtonToggleFoundation<>>Advanced: A reference to the MDCFoundation. Only for Toggleable buttons.
iconIconPropTIcon for the button
labelstringApply an aria label.
onChange(evt: IconButtonOnChangeEventT) => voidAn onChange callback that receives a custom event. evt.detail = { isOn: boolean }
onIconIconPropTIf specified, renders a toggle with this icon as the on state.
rippleRipplePropTAdds a ripple effect to the component

CardActionButton

A card action Button

Props

NameTypeDescription
childrenReactNodeContent specified as children.
dangerbooleanUsed to indicate a dangerous action.
densebooleanMake the Button dense.
disabledbooleanMake the button disabled
iconIconPropTAn Icon for the Button
labelanyContent specified as a label prop.
outlinedbooleanMake the button outlined.
raisedbooleanMake the Button raised.
rippleRipplePropTAdds a ripple effect to the component
touchbooleanMakes the button more touch friendly. This will automatically be set true if used inside of TouchTargetWrapper.
trailingIconIconPropTA trailing icon for the Button
unelevatedbooleanMake the button unelevated.
14.3.5

23 days ago

14.3.4

2 months ago

14.3.3

3 months ago

14.2.7

5 months ago

14.2.8

5 months ago

14.2.9

5 months ago

14.2.5

5 months ago

14.2.6

5 months ago

14.3.0

4 months ago

14.3.1

4 months ago

14.3.2

3 months ago

14.2.2

7 months ago

14.2.0

7 months ago

14.2.1

7 months ago

14.1.5

7 months ago

14.1.4

8 months ago

14.1.3

8 months ago

14.1.2

8 months ago

14.1.1

8 months ago

14.1.0

9 months ago

14.0.12

9 months ago

14.0.11

9 months ago

14.0.10

9 months ago

14.0.9

10 months ago

14.0.8

10 months ago

14.0.7

10 months ago

14.0.6

10 months ago

14.0.5

11 months ago

14.0.4

12 months ago

14.0.1-alpha.0

1 year ago

14.0.2-alpha.3

1 year ago

14.0.2-alpha.0

1 year ago

14.0.2-alpha.1

1 year ago

14.0.2-alpha.6

1 year ago

14.0.2-alpha.7

1 year ago

14.0.2-alpha.4

1 year ago

14.0.2-alpha.5

1 year ago

14.0.0

12 months ago

14.0.1

12 months ago

14.0.0-alpha.0

1 year ago

14.0.2

12 months ago

14.0.3

12 months ago

8.0.8

1 year ago

8.0.7

2 years ago

8.0.6

2 years ago

8.0.5

2 years ago

8.0.4

2 years ago

8.0.3

2 years ago

8.0.2

2 years ago

8.0.1

2 years ago

8.0.0

2 years ago

7.0.3

3 years ago

7.0.2

3 years ago

7.0.1

3 years ago

7.0.0

3 years ago

6.1.4

4 years ago

6.1.3

4 years ago

6.1.2

4 years ago

6.0.14

5 years ago

6.0.13

5 years ago

6.0.12

5 years ago

6.0.11

5 years ago

6.0.10

5 years ago

6.0.9

5 years ago

6.0.5

5 years ago

6.0.4

5 years ago

6.0.3

5 years ago

6.0.1

5 years ago

6.0.0

5 years ago

6.0.2

5 years ago

6.0.0-rc.5

5 years ago

6.0.0-rc.4

5 years ago

6.0.0-rc.3

5 years ago

6.0.0-rc.1

5 years ago

6.0.0-rc.2

5 years ago

6.0.0-rc.0

5 years ago

6.0.0-alpha.16

5 years ago

6.0.0-alpha.14

5 years ago

6.0.0-alpha.15

5 years ago

6.0.0-alpha.13

5 years ago

6.0.0-alpha.12

5 years ago

6.0.0-alpha.11

5 years ago

6.0.0-alpha.7

5 years ago

5.7.2

5 years ago

6.0.0-alpha.5

5 years ago

6.0.0-alpha.6

5 years ago

6.0.0-alpha.3

5 years ago

5.7.0

5 years ago

5.6.0

5 years ago

5.5.2

5 years ago

5.5.1

6 years ago

5.5.0

6 years ago

5.4.3

6 years ago

5.4.2

6 years ago

5.4.1

6 years ago

5.4.0

6 years ago

5.3.1

6 years ago

5.3.0

6 years ago

5.2.2

6 years ago

5.2.1

6 years ago

5.2.0

6 years ago

5.2.0-alpha.1

6 years ago

5.2.0-alpha.0

6 years ago

5.1.8

6 years ago

5.1.7

6 years ago

5.1.6

6 years ago

5.1.5

6 years ago

5.1.4

6 years ago

5.1.3

6 years ago

5.1.2

6 years ago

5.1.1

6 years ago

5.1.0

6 years ago

5.0.30-rc.0

6 years ago

5.0.29-rc.0

6 years ago

5.0.28-rc.0

6 years ago

5.0.27-rc.0

6 years ago

5.0.26-rc.0

6 years ago

5.0.25-rc.0

6 years ago

5.0.24-rc.0

6 years ago

5.0.23-rc.0

6 years ago

5.0.23-alpha.0

6 years ago

5.0.22-alpha.0

6 years ago

5.0.21-alpha.0

6 years ago

5.0.20-alpha.0

6 years ago

5.0.19-alpha.0

6 years ago

5.0.18-alpha.0

6 years ago

5.0.17-alpha.0

6 years ago

5.0.16-alpha.0

6 years ago

5.0.15-alpha.0

6 years ago

5.0.14-alpha.0

6 years ago

5.0.13-alpha.0

6 years ago

5.0.12-alpha.0

6 years ago

5.0.11-alpha.0

6 years ago

5.0.8-alpha.0

6 years ago

5.0.7-alpha.0

6 years ago

5.0.6-alpha.0

6 years ago

5.0.5-alpha.0

6 years ago

5.0.4-alpha.0

6 years ago

5.0.3-alpha.0

6 years ago

5.0.2-alpha.0

6 years ago

5.0.1-alpha.0

6 years ago

5.0.0-alpha.0

6 years ago

4.0.6

6 years ago

4.0.5

6 years ago

4.0.4

6 years ago

4.0.3

6 years ago

4.0.2

6 years ago

4.0.1

6 years ago

4.0.0

6 years ago

3.0.11

6 years ago

3.0.10

6 years ago

3.0.9

6 years ago

3.0.8

6 years ago

3.0.7

6 years ago

3.0.6

6 years ago

3.0.5

6 years ago

3.0.4

6 years ago

3.0.3

6 years ago

3.0.0

6 years ago

2.2.2

6 years ago

2.2.0

6 years ago

2.1.3

6 years ago

2.1.2

6 years ago

2.1.0

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

2.0.0-alpha.7

6 years ago

2.0.0-alpha.6

6 years ago

2.0.0-alpha.5

6 years ago

2.0.0-alpha.4

6 years ago

2.0.0-alpha.3

6 years ago

2.0.0-alpha.2

6 years ago

2.0.0-alpha.1

6 years ago

2.0.0-alpha.0

6 years ago

1.10.1-alpha.0

6 years ago

1.10.0-alpha.0

6 years ago