Newskit Logo

Icons

Overview

Icons are small SVG shapes, ranging from basic UI shapes to brand logos. NewsKit contains a default set but any of these can be overriden by providing a React component in the icons section of your theme.

Usage

Icons can be used to enhance other elements and content, as well as used inside links or buttons when space is limited.

Available Icons

NamePreview
IconFilledYoutube
IconFilledGitHub
IconFilledFacebook
IconFilledTwitter
IconFilledWhatsApp
IconFilledFigma

Props

Icons must have a size specified, and some also support an optional colour override.

titlestring
This optional prop adds title to the svg image in order to make it accessible and visible for screen readers. If your icon is just decorative and not part of the content this prop can be ommited, otherwise it should be passed.
overridesobject
If provided, overrides the respective presets for the component and provided elements.
stylePresetMQ<string>
If provided, this overrides the style preset applied to the svg.
sizeMQ<string>
If provided, this overrides the size of the icon.

Playground

Size
import React from 'react';
import { Facebook } from 'newskit';

export default () => (
  <Facebook overrides={{ size: 'iconSize040' }} />
);

Create NewsKit icons

With the help of the customToNewsKitIcon util function, each SVG icon can be easily turned into a Newskit icon that works well with theme tokens and getFromTheme util functions. The only requirement is to wrap the SVG markup within an Svg component and pass props to it.

The following example shows how the SVG component should be used:


  <Svg {...props} viewBox="0 0 429 422">
    <g fill="none" fill-rule="evenodd" transform="translate(-77.000000, -1738.000000) translate(77.000000, 1738.500000)">
      <circle cx="250.5" cy="242.5" r="178" style="mix-blend-mode:multiply"/>
      <circle cx="195" cy="195" r="195" style="mix-blend-mode:multiply"/>
    </g>
  </Svg>
 

Use customToNewsKitIcon utility function to make the svg icon compatible with NewsKit:


export const IconFilledFacebook = customToNewsKitIcon(
  'IconFilledFacebook',
  props => (
    <Svg {...props} viewBox="0 0 24 24">
      <path
        fillRule="nonzero"
        d="M13.0784931,22.2595724 L13.0784931,13.1365112 L16.2002321,13.1365112 L16.6676019,9.5811424 L13.0784931,9.5811424 L13.0784931,7.31114568 C13.0784931,6.28180493 13.3699223,5.58025387 14.8748197,5.58025387 L16.7941176,5.57938466 L16.7941176,2.39951562 C16.4620261,2.35634473 15.3227937,2.25957241 13.9973813,2.25957241 C11.2301818,2.25957241 9.33569472,3.916388 9.33569472,6.9592112 L9.33569472,9.58123898 L6.20588235,9.58123898 L6.20588235,13.1366078 L9.33559627,13.1366078 L9.33559627,22.2595724 L13.0784931,22.2595724 Z"
      />
    </Svg>
  ),
);
 

Rationale

Accessibility

Where icon colour can be overidden, the icon must have a 3:1 minimum contrast ratio with its background.