react-iztro
react-iztro provides Iztrolabe, a ready-made React component for displaying the twelve palaces(十二宮), stars(星曜), four transformations(四化), and the three harmonious palaces and the opposite palace(三方四正). You can change horoscope periods within the chart. To build your own interface, use iztro-hook to get the data directly.
Installation
npm install iztro react-iztroThe examples and props below are based on react-iztro 1.5.1.
Display a chart
import React from 'react';
import { astro } from 'iztro';
import { Iztrolabe } from 'react-iztro';
astro.setLanguage('en-US');
export default function App() {
return (
<div style={{ maxWidth: 1024, margin: '0 auto' }}>
<Iztrolabe
birthday="2000-8-16"
birthdayType="solar"
birthTime={2}
gender="female"
lang="en-US"
horoscopeDate="2026-11-22"
horoscopeHour={2}
/>
</div>
);
}Scroll here to load the runnable example.
The component loads its own styles, so your build tool must support importing CSS from dependencies. Set the chart width with a wrapper and override the default styles in your application stylesheet.
lang sets the language of the chart data. The example also calls astro.setLanguage() so the labels in the central palace use the same language. Set it once when your application starts.
Component props
Iztrolabe accepts the chart inputs for useIztro. birthday, birthdayType, birthTime, and gender are required. The component also provides these display and horoscope props.
| Parameter | Type | Description |
|---|---|---|
horoscopeDate | string | Date | Gregorian date for the horoscope query. Defaults to the current local date. |
horoscopeHour | number | Double-hour index for the hourly horoscope(流時), from 0 to 12. The component defaults to 0 (early Zi hour, 早子時). |
centerPalaceAlign | boolean | Set to true to center the content of the central palace(中宮). |
You can adjust the horoscope date and double-hour in the central palace. The query also updates when the parent changes horoscopeDate or horoscopeHour. To use the double-hour of a particular Date, pass the converted index as horoscopeHour.
Switch Zhongzhou chart types
The component uses the standard chart calculation by default. Switch to the Zhongzhou school(中州派) in the central palace to choose a natal chart(天盤), earth chart(地盤), or human chart(人盤). To open a Zhongzhou earth chart directly, add these two props to the component above.
options={{ algorithm: 'zhongzhou' }}
astroType="earth"See AstroType and Config for chart types and other configuration options.