Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource


Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.






                const {Observable} = Rx;
const {div, input, label, h1, VNode, makeDOMDriver} = CycleDOM;
const isolate = CycleIsolate.default;

type Sources = {
  DOM: Cycle.DOMSource;

type Sinks = {
  DOM: Observable<Cycle.VNode>;

type Props = {
  label: string;
  unit: string;
  min: number;
  max: number;
  init?: number;
  value?: number;

function LabeledSlider(so: {DOM: Cycle.DOMSource, props$: Observable<Props>}): {DOM: Observable<VNode>, value: Observable<number>} {
  const change$ = intent(so.DOM);
  const state$ = model(change$, so.props$);
  const vdom$ = view(state$);
  return {
    DOM: vdom$,
    value: state$.map(state => state.value)

function intent(DOM: Cycle.DOMSource): Observable<number> {
    .map((ev: Event): number => Number((ev.currentTarget as HTMLInputElement).value));

function model(newValue$: Observable<number>, props$: Observable<Props>): Observable<Props> {
  const initialValue$ = props$.map(props => props.init);
  const value$ = initialValue$.concat(newValue$);
  return Observable.combineLatest(
    (value, props) => {
      return {
        label: props.label,
        unit: props.unit,
        min: props.min,
        max: props.max,

function view(state$: Observable<Props>): Observable<Vnode> {
  return state$.map(state => {
    return div('.labeled-slider', [
      label(`${state.label}: ${state.value} ${state.unit}`),
      input('.labeled-slider__control', { attrs: { type: 'range', min: state.min, max: state.max ,value: state.value} })

function main(sources: Sources): Sinks { 
  // Weight Slider
  const weightProps$ = Observable.of({
    label: 'Weight',
    unit: 'kg',
    min: 40,
    max: 150,
    init: 70
  const WeightSlider = isolate(LabeledSlider, 'weight');
  const weightSinks = WeightSlider({DOM: sources.DOM, props$: weightProps$});
  const weightVDom$ = weightSinks.DOM;
  const weightValue$ = weightSinks.value;
  // Height Slider
  const heightProps$ = Observable.of({
    label: 'Height',
    unit: 'cm',
    min: 140,
    max: 220,
    init: 170
  const HeightSlider = isolate(LabeledSlider, 'height');
  const heightSinks = HeightSlider({DOM: sources.DOM, props$: heightProps$});
  const heightVDom$ = heightSinks.DOM;
  const heightValue$ = heightSinks.value;
  // 現在の BMI 値を取得 ( State )
  const bmi$ = Observable.combineLatest(
    (weight: number, height: number) => {
      const heightMeters = height * 0.01;
      const bmi = Math.round(weight / (heightMeters * heightMeters));
      return bmi;
  const vdom$ = Observable.combineLatest(
    (bmi, weightDOM, heightDOM) => {
      return div([
        h1(`BMI is ${bmi}`)
  return {
    DOM: vdom$

const drivers = {
  DOM: makeDOMDriver('#app')
};, drivers);