Skip to main content

SDK Props Reference

VoteNowButton Props

PropTypeRequiredDescription
URLstringYesThe voting URL obtained from the VOTR API
labelstringNoButton text (default: "Vote Now")
buttonStyleViewStyleNoCustom styling for the button
textStyleTextStyleNoCustom styling for the button text
isDisabledbooleanNoWhether the button is disabled
onPress() => voidNoCalled when the button is pressed
onSuccess() => voidNoCalled when voting completes successfully
onError(error: string) => voidNoCalled when an error occurs
onBack() => voidNoCalled when the user closes the voting modal

Example with All Props

<VoteNowButton
URL={votingUrl}
label="Submit Your Vote"
buttonStyle={{
backgroundColor: "#28a745",
borderRadius: 12,
paddingVertical: 16,
paddingHorizontal: 32,
elevation: 3,
shadowColor: "#000",
shadowOffset: { width: 0, height: 2 },
shadowOpacity: 0.25,
shadowRadius: 3.84,
}}
textStyle={{
color: "#ffffff",
fontSize: 18,
fontWeight: "600",
textAlign: "center",
}}
isDisabled={!votingUrl}
onPress={() => console.log("Vote button pressed")}
onSuccess={() => {
Alert.alert("Success", "Vote submitted successfully!");
navigation.goBack();
}}
onError={(error) => {
console.error("Voting error:", error);
Alert.alert("Error", "Failed to submit vote. Please try again.");
}}
onBack={() => {
console.log("User cancelled voting");
}}
/>

Advanced Usage with Custom Styling

<VoteNowButton
URL={votingUrl}
label="Cast Your Vote"
buttonStyle={{
backgroundColor: "#007AFF",
borderRadius: 8,
paddingVertical: 12,
paddingHorizontal: 24,
shadowColor: "#000",
shadowOffset: { width: 0, height: 2 },
shadowOpacity: 0.25,
shadowRadius: 3.84,
elevation: 5,
}}
textStyle={{
color: "white",
fontSize: 16,
fontWeight: "bold",
}}
onSuccess={() => {
Alert.alert("Success", "Your vote has been recorded!");
}}
onError={(error) => {
Alert.alert("Error", `Voting failed: ${error}`);
}}
/>