Skip to main content

Course

The Course component displays timetable course information with colors, status indicators, and teacher/room details.

Import

import { Course } from 'papillon-ui';

Basic Usage

<Course
  id="math-101"
  name="Mathematics"
  teacher="Mr. Smith"
  room="Room 204"
  color="#4A90E2"
  start={Date.now() / 1000}
  end={Date.now() / 1000 + 3600}
  onPress={() => {}}
/>

Props

id
string
required
Unique identifier for the course
name
string
required
Course name/subject
teacher
string
Teacher name
room
string
Room number or location
color
string
Course color (hex)
start
number
required
Start timestamp (Unix seconds)
end
number
required
End timestamp (Unix seconds)
status
object
Status object with canceled boolean and label string
variant
'primary' | 'separator'
default:"primary"
Display variant. Use separator for breaks between courses.
showTimes
boolean
default:true
Show start/end times on the left
compact
boolean
default:false
Compact mode with reduced padding
skeleton
boolean
default:false
Loading skeleton state

Status Indicators

Canceled Course

<Course
  name="Mathematics"
  start={startTime}
  end={endTime}
  status={{ canceled: true, label: "Cours annulé" }}
  color="#DC1400"
/>

Modified Course

<Course
  name="Mathematics"
  start={startTime}
  end={endTime}
  status={{ label: "Salle modifiée" }}
  color="#4A90E2"
/>

Separator Variant

Display breaks between courses:
<Course
  id="lunch"
  name="Lunch Break"
  variant="separator"
  start={12 * 3600}
  end={13 * 3600}
/>

Compact Mode

<Course
  name="Mathematics"
  teacher="Mr. Smith"
  room="204"
  start={startTime}
  end={endTime}
  compact
/>

Full Example

import { Course } from 'papillon-ui';
import { View } from 'react-native';

function TimetableDay({ courses }) {
  return (
    <View style={{ gap: 6 }}>
      {courses.map(course => (
        <Course
          key={course.id}
          id={course.id}
          name={course.subject}
          teacher={course.teacher}
          room={course.room}
          color={course.color}
          start={course.startTimestamp}
          end={course.endTimestamp}
          status={course.status}
          onPress={() => showCourseDetails(course)}
        />
      ))}
    </View>
  );
}

Build docs developers (and LLMs) love