Skip to content

Main content

Random Hex Color Generator Source Code

Browse the implementation files for Random Hex Color Generator.
tool.ts typescript
import { calculateRandomHexColor } from '@tool.io/tools/random/hex-color';
import type { RandomSource } from '@tool.io/tools/random/number';

export { calculateRandomHexColor };

export const randomHexColor = (
	random: RandomSource = Math.random
): string => {
	const value = calculateRandomHexColor(random);

	return value?.hex ?? '';
};

export const Tool: TypeTool = {
	name: 'Random Hex Color Generator',
	slug: 'random/hex-color',
	intro: 'Generate a random six-digit hexadecimal CSS color.',
	tool: randomHexColor,
	i: [],
	o: [
		{
			example: '#7F2A9C',
			label: 'Random hex color',
			placeholder: 'Random hex color',
			render: 'textarea',
			type: 'text'
		}
	],
	rerunnable: true,
	alternative: [
		{
			title: 'Random Hexadecimal Value',
			url: '/random/hexadecimal'
		},
		{ title: 'Random Number', url: '/random/number' }
	],
	cite: [
		{
			title: 'Web colors - Wikipedia',
			url: 'https://en.wikipedia.org/wiki/Web_colors'
		}
	]
};

export default Tool;

Description

Browse the implementation files for Random Hex Color Generator.

References

  1. Tool.io on GitHub
  2. Tool.io TypeScript tools library

Similar or alternative tools