Colors
Predefined colors for use in your application.
Visual Reference
<template>
<Column :gap="20">
<Column :gap="10">
<Text data="Material Colors" :style="{ fontSize: 18, fontWeight: 'bold' }" />
<Wrap :spacing="10" :run-spacing="10">
<ColorItem name="Colors.red" :color="Colors.red" />
<ColorItem name="Colors.pink" :color="Colors.pink" />
<ColorItem name="Colors.purple" :color="Colors.purple" />
<ColorItem name="Colors.deepPurple" :color="Colors.deepPurple" />
<ColorItem name="Colors.indigo" :color="Colors.indigo" />
<ColorItem name="Colors.blue" :color="Colors.blue" />
<ColorItem name="Colors.lightBlue" :color="Colors.lightBlue" />
<ColorItem name="Colors.cyan" :color="Colors.cyan" />
<ColorItem name="Colors.teal" :color="Colors.teal" />
<ColorItem name="Colors.green" :color="Colors.green" />
<ColorItem name="Colors.lightGreen" :color="Colors.lightGreen" />
<ColorItem name="Colors.lime" :color="Colors.lime" />
<ColorItem name="Colors.yellow" :color="Colors.yellow" />
<ColorItem name="Colors.amber" :color="Colors.amber" />
<ColorItem name="Colors.orange" :color="Colors.orange" />
<ColorItem name="Colors.deepOrange" :color="Colors.deepOrange" />
<ColorItem name="Colors.brown" :color="Colors.brown" />
<ColorItem name="Colors.grey" :color="Colors.grey" />
<ColorItem name="Colors.blueGrey" :color="Colors.blueGrey" />
</Wrap>
</Column>
<Column :gap="10">
<Text data="Shades Example (Blue)" :style="{ fontSize: 18, fontWeight: 'bold' }" />
<Wrap :spacing="10" :run-spacing="10">
<ColorItem name="Colors.blue50" :color="Colors.blue50" />
<ColorItem name="Colors.blue100" :color="Colors.blue100" />
<ColorItem name="Colors.blue200" :color="Colors.blue200" />
<ColorItem name="Colors.blue300" :color="Colors.blue300" />
<ColorItem name="Colors.blue400" :color="Colors.blue400" />
<ColorItem name="Colors.blue500" :color="Colors.blue500" />
<ColorItem name="Colors.blue600" :color="Colors.blue600" />
<ColorItem name="Colors.blue700" :color="Colors.blue700" />
<ColorItem name="Colors.blue800" :color="Colors.blue800" />
<ColorItem name="Colors.blue900" :color="Colors.blue900" />
</Wrap>
</Column>
<Column :gap="10">
<Text data="Cupertino Colors" :style="{ fontSize: 18, fontWeight: 'bold' }" />
<Wrap :spacing="10" :run-spacing="10">
<ColorItem name="CupertinoColors.activeBlue" :color="CupertinoColors.activeBlue" />
<ColorItem name="CupertinoColors.activeGreen" :color="CupertinoColors.activeGreen" />
<ColorItem name="CupertinoColors.activeOrange" :color="CupertinoColors.activeOrange" />
<ColorItem name="CupertinoColors.destructiveRed" :color="CupertinoColors.destructiveRed" />
<ColorItem name="CupertinoColors.systemBlue" :color="CupertinoColors.systemBlue" />
<ColorItem name="CupertinoColors.systemGreen" :color="CupertinoColors.systemGreen" />
<ColorItem name="CupertinoColors.systemRed" :color="CupertinoColors.systemRed" />
<ColorItem name="CupertinoColors.systemGrey" :color="CupertinoColors.systemGrey" />
</Wrap>
</Column>
</Column>
</template>
<script setup lang="ts">
import {
Colors,
CupertinoColors,
Column,
Wrap,
Container,
Text,
BorderRadius,
EdgeInsets,
BoxDecoration,
Border,
} from "fluekit";
import { defineComponent, h } from "vue";
const ColorItem = defineComponent({
props: {
name: String,
color: String,
},
setup(props) {
return () =>
h(Column, { alignment: "center" }, () => [
h(
Container,
{
width: 80,
height: 80,
decoration: BoxDecoration({
color: props.color,
borderRadius: BorderRadius.circular(8),
border: Border.all({ color: "#E0E0E0", width: 1 }),
}),
alignment: "center",
},
() =>
h(Text, {
data: props.color,
style: { fontSize: 10, color: "#fff", textShadow: "0 0 2px rgba(0,0,0,0.5)" },
}),
),
h(Container, { height: 4 }),
h(Text, {
data: props.name,
style: { fontSize: 10, color: "#666", textAlign: "center", width: 80 },
}),
]);
},
});
</script>Material Colors
The Colors object contains the standard Material Design color palette.
Usage
<script setup lang="ts">
import { Colors, Container, Text } from "fluekit";
</script>
<template>
<Container :color="Colors.red">
<Text data="Red Background" :style="{ color: Colors.white }" />
</Container>
<Container :color="Colors.blue500">
<Text data="Blue 500" />
</Container>
</template>Available Colors
Standard colors include:
transparentblack,black87,black54, etc.white,white70,white60, etc.red,pink,purple,deepPurpleindigo,blue,lightBlue,cyanteal,green,lightGreen,limeyellow,amber,orange,deepOrangebrown,grey,blueGrey
Each color usually has shades from 50 to 900 (e.g., red50, red100, ..., red900) and accent variations (e.g., redAccent, redAccent100, ..., redAccent700).
Cupertino Colors
The CupertinoColors object contains the standard iOS color palette.
Usage
<script setup lang="ts">
import { CupertinoColors, Container, Text } from "fluekit";
</script>
<template>
<Container :color="CupertinoColors.systemBlue">
<Text data="System Blue" :style="{ color: CupertinoColors.white }" />
</Container>
</template>Available Colors
Standard colors include:
activeBlue,activeGreen,activeOrangewhite,blacklightBackgroundGray,extraLightBackgroundGray,darkBackgroundGraylabel,secondaryLabel,tertiaryLabel,quaternaryLabelsystemBlue,systemGreen,systemIndigo,systemOrange,systemPink,systemPurple,systemRed,systemTeal,systemYellow,systemGreysystemBackground,secondarySystemBackground,tertiarySystemBackgroundsystemGroupedBackground,secondarySystemGroupedBackground,tertiarySystemGroupedBackgroundseparator,opaqueSeparatorlinkdestructiveRed
Color Manipulation
Both Colors and CupertinoColors include helper methods for color manipulation.
withOpacity
Returns a new color with the specified opacity (0.0 to 1.0).
<script setup lang="ts">
import { Colors, Container, Text } from "fluekit";
</script>
<template>
<!-- Red with 50% opacity -->
<Container :color="Colors.withOpacity(Colors.red, 0.5)">
<Text data="Semi-transparent Red" />
</Container>
</template>Or use the standalone utility:
import { ColorUtils } from "fluekit";
const myColor = ColorUtils.withOpacity("#000000", 0.5); // rgba(0, 0, 0, 0.5)lighten
Lightens a color by a percentage (0.0 to 1.0).
const lightRed = Colors.lighten(Colors.red, 0.2); // 20% lighterdarken
Darkens a color by a percentage (0.0 to 1.0).
const darkBlue = Colors.darken(Colors.blue, 0.2); // 20% darkerColor Class
Colors and CupertinoColors now return Color instances instead of strings. The Color class provides methods similar to Flutter's Color class.
import { Colors, Color } from "fluekit";
const red = Colors.red;
// Get properties
console.log(red.red); // 244
console.log(red.green); // 67
console.log(red.blue); // 54
console.log(red.alpha); // 255
console.log(red.opacity); // 1.0
// Methods
const semiTransparentRed = red.withOpacity(0.5);
const newColor = red.withRed(100);toString()
The Color object's toString() method returns a CSS-compatible string (e.g., rgba(255, 0, 0, 1)), so it can be used directly in style bindings.
<div :style="{ backgroundColor: Colors.red }"></div>withAlpha / withRed / withGreen / withBlue
Modify specific channels of a color.
// Set alpha channel (0-255)
const semiTransparent = Colors.withAlpha(Colors.red, 128);
// Replace red channel (0-255)
const modifiedRed = Colors.withRed(Colors.blue, 100);computeLuminance
Returns the relative luminance of the color (0.0 to 1.0).
const lum = Colors.computeLuminance(Colors.white); // 1.0
const isDark = Colors.computeLuminance(myColor) < 0.5;