Code

Displays code inline in text.

It implements the <code> element.

Styles

Import the styles within a Next.js custom app in pages/_app.js.
import 'device-agnostic-ui/public/components/Code.css';

Props

Use any valid <code> props.

Examples

Deep import.
import Code from 'device-agnostic-ui/public/components/Code.js';
Deep require.
const Code = require('device-agnostic-ui/public/components/Code.js');
Index import. Convenient, but technically inferior to a deep import.
import { Code } from 'device-agnostic-ui';
Index require. Convenient, but technically inferior to a deep require.
const { Code } = require('device-agnostic-ui');
Non-HTML code.
import { Code } from 'device-agnostic-ui';

const result = <Code>window</Code>;
window
Code in a link.
import { Code, LinkText } from 'device-agnostic-ui';

const result = (
  <LinkText href="https://developer.mozilla.org/en-US/docs/Web/API/Window">
    <Code>window</Code>
  </LinkText>
);
HTML code.
import { Code } from 'device-agnostic-ui';

const result = <Code>{'<strong>'}</Code>;
<strong>

Tags